首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OneNote添加: TableCell内容

OneNote添加: TableCell内容
EN

Stack Overflow用户
提问于 2016-11-26 19:51:46
回答 1查看 90关注 0票数 0

OneNote外接程序的文档向我们展示了如何获取表单元格。在下面的代码片段(文档示例中的一些小修改)中,我在0,0位置加载了一个表单元格。但是,一旦我得到了TableCell,就不清楚如何加载它的contents。我如何知道TableCell的内部包含什么?有什么办法可以做吗

代码语言:javascript
复制
var cell = table.getCell(0,0);
cell.getContents();//Is this correct?

或者,由于内部内容未知,这不是思考获取模式的正确方式吗?

谢谢!

代码语言:javascript
复制
OneNote.run(function(ctx) {
	var app = ctx.application;
	var outline = app.getActiveOutline();

	// Queue a command to load outline.paragraphs and their types.
	ctx.load(outline, "paragraphs, paragraphs/type");

	// Run the queued commands, and return a promise to indicate task completion.
	return ctx.sync().then(function () {
		var paragraphs = outline.paragraphs;

		// for each table, append a column.
		for (var i = 0; i < paragraphs.items.length; i++) {
			var paragraph = paragraphs.items[i];
			if (paragraph.type == "Table") {
				var table = paragraph.table;
				var cell = table.getCell(0,0);
				//To do - how to get value inside?
			}
		}
		return ctx.sync();
	})
})
.catch(function(error) {
	console.log("Error: " + error);
	if (error instanceof OfficeExtension.Error) {
		console.log("Debug info: " + JSON.stringify(error.debugInfo));
	}
});

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-28 18:36:15

请参阅表格单元格的正式文档:https://github.com/OfficeDev/office-js-docs/blob/master/reference/onenote/tablecell.md

表格单元格只包含段落。这些段落可以是丰富的文本、图像、轮廓,甚至还有另一张带有桌布和桌球的表格。

要了解表单元格中的内容,您必须加载带有子段类型的子段,然后根据它们的类型加载子段属性(就像在代码中那样)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40822484

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档