Why worksheet Id changing after reopening document (Excel javascript API )?

风格不统一 提交于 2019-12-10 23:45:23

问题


In my Excel tab-pane addin after adding worksheet(manually/programmatically) and running code below I have worksheet object where id is "{040E0F18-0F61-4CD9-886D-95112C925793}", then I save workbook, close and open again, run code below and it shows me that the worksheet.id now is "{00000000-0001-0000-0000-000000000000}"! In office.js reference about worksheet 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);
          });
  });

回答1:


The documentation was (very) recently updated to clarify this. The ID shouldn't change within the same session (i.e. while the document is open). They do however change between sessions (i.e. when a document is opened and closed).

From the latest documentation:

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.



来源:https://stackoverflow.com/questions/37843510/why-worksheet-id-changing-after-reopening-document-excel-javascript-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!