为什么工作表 ID 在重新打开文档后发生变化 (Excel javascript API )?
Why worksheet Id changing after reopening document (Excel javascript API )?
在我的 Excel 选项卡窗格插件中添加工作表 (manually/programmatically) 和下面的 运行ning 代码后,我有工作表对象,其中 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 was (very) 最近更新以澄清这一点。 ID 不应在同一会话中更改(即当文档打开时)。然而,它们确实会在会话之间发生变化(即打开和关闭文档时)。
来自最新文档:
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.
在我的 Excel 选项卡窗格插件中添加工作表 (manually/programmatically) 和下面的 运行ning 代码后,我有工作表对象,其中 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 was (very) 最近更新以澄清这一点。 ID 不应在同一会话中更改(即当文档打开时)。然而,它们确实会在会话之间发生变化(即打开和关闭文档时)。
来自最新文档:
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.