OneNote 加载项的文档向我们展示了如何获取表格单元格。在下面的代码片段中(对文档示例的细微修改),我在位置 [0,0] 处加载了一个表格单元格。但是,一旦我得到TableCell
它,就不清楚我如何加载它的内容。我怎么知道a的内部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));
}
});