在添加工作表(手动/编程)并运行下面的代码后,在我的 Excel 选项卡 Pane 插件中我有工作表对象,其中 id 为“{040E0F18-0F61-4CD9-886D-95112C925793}”,然后我保存工作簿,关闭并再次打开,运行下面的代码,它告诉我 worksheet.id 现在是“{00000000-0001-0000-0000-000000000000}”! 在 office.js reference关于工作表 ID:
The value of the identifier remains the same even when the worksheet is renamed or moved. Read-only.
Excel.run(function (ctx) {
var sheet = ctx.workbook.worksheets.getActiveWorksheet().load('name');
return ctx.sync().then(function () {
console.log(sheet);
});
});
最佳答案
documentation是 ( very ) 最近更新以澄清这一点。 ID 不应在同一 session 中更改(即当文档打开时)。然而,它们确实会在 session 之间发生变化(即打开和关闭文档时)。
来自最新的文档:
Returns a value that uniquely identifies the worksheet in a given workbook. The value of the identifier remains the same even when the worksheet is renamed or moved. Values change with each session of the file being opened. Read-only.
关于javascript - 为什么工作表 ID 在重新打开文档(Excel javascript API)后发生变化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37843510/