为什么在重新打开文档(Excel javascript API)后,工作表Id更改? [英] Why worksheet Id changing after reopening document (Excel javascript API )?

查看:155
本文介绍了为什么在重新打开文档(Excel javascript API)后,工作表Id更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Excel选项卡窗格添加工作表(手动/编程)和运行代码后,我有工作表对象,其中id是{040E0F18-0F61-4CD9-886D-95112C925793},然后我保存工作簿,关闭和再次打开,运行下面的代码,它显示我的工作表。现在是{00000000-0001-0000-0000-000000000000}!
在office.js中参考关于工作表ID:

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);
          });
  });


推荐答案

文档是(非常)最近更新澄清这一点。 ID不应在同一会话内(即文档打开时)更改。然而,它们在会话之间改变(即当文档被打开和关闭时)。

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).

从最新的文档中:


返回唯一标识工作表的值在给定的
工作簿。即使
工作表被重命名或移动,标识符的值也保持不变。值将随着
文件的每个会话被打开而改变。只读。

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 javascript API)后,工作表Id更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆