excel办公室js库中的范围格式的autofitColumns不工作

它似乎autofitColumns范围格式在办公室js的Excel API a 1.1不能正常工作,或者我没有正确使用它

代码示例:

Excel.run(function (ctx) { var sheet = ctx.workbook.worksheets.getActiveWorksheet(); sheet.getRange("A1:B2").format.autofitColumns(); return ctx.sync(); }) .catch(function errorHandler(error) { console.log("Error: " + JSON.stringify(error)); if (error instanceof OfficeExtension.Error) { console.log("Debug info: " + JSON.stringify(error.debugInfo)); }); 

错误对象如下。

 Error: {"description":"Object doesn't support property or method 'autofitColumns'","number":-2146827850,"stack":"TypeError: Object doesn't support property or method 'autofitColumns'\n at .... 

我也尝试加载“格式”和/或“格式/ *”先同步,但也没有工作

我正在运行Excel 2016 Windows 64位版本

自动安装仅在ExcelApi 1.2中添加(您可以在智能search注释中看到该方法)。 所以,如果我不得不猜测,我不知道你是否在Office 2016的RTM / MSI版本。如果你做一个运行时检查需求集,你是否得到Office.context.requirements.isSetSupported('ExcelApi', 1.1)返回true,但与1.2相同的调用返回false?