excel office js 库中范围格式的 autofitColumns 不工作

autofitColumns for range format in excel office js library not working

excel api office js 1.1 中的范围格式的 autofitColumns 似乎无法正常工作或我没有正确使用它

代码示例:

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

我也试过先加载 "format" and/or "format/*" 然后同步,但也没有用

我运行反对Excel2016windows64位版本

自动拟合仅在 ExcelApi 1.2 中添加(您可以在该方法的智能感知注释中看到)。因此,如果我不得不猜测,我想知道您是否使用 RTM/MSI 版本的 Office 2016。如果您对需求集进行运行时检查,您是否得到 Office.context.requirements.isSetSupported('ExcelApi', 1.1) return true , 但与 1.2 returns false?

相同的调用