OneNote外接程序的文档向我们展示了如何获取表单元格。在下面的代码片段(文档示例中的一些小修改)中,我在0,0位置加载了一个表单元格。但是,一旦我得到了TableCell,就不清楚如何加载它的contents。我如何知道TableCell的内部包含什么?有什么办法可以做吗
var cell = table.getCell(0,0);
cell.getContents();//Is this correct?或者,由于内部内容未知,这不是思考获取模式的正确方式吗?
谢谢!
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));
}
});
发布于 2016-11-28 18:36:15
请参阅表格单元格的正式文档:https://github.com/OfficeDev/office-js-docs/blob/master/reference/onenote/tablecell.md
表格单元格只包含段落。这些段落可以是丰富的文本、图像、轮廓,甚至还有另一张带有桌布和桌球的表格。
要了解表单元格中的内容,您必须加载带有子段类型的子段,然后根据它们的类型加载子段属性(就像在代码中那样)。
https://stackoverflow.com/questions/40822484
复制相似问题