首页 > 解决方案 > Office Addin Excel 不保存

问题描述

我正在使用 office.js 通过我的 office-addin 与 Excel 进行交互。微软文档说我们可以使用下面的代码保存 Excel,但它一直给我这个控制台错误

TypeError: context.workbook.save is not a function

链接到 Microsoft 文档 - https://docs.microsoft.com/en-us/javascript/api/excel/excel.workbook?view=excel-js-preview#save_saveBehavior _

await Excel.run(async (context) => {
                    if (Office.context.requirements.isSetSupported('ExcelAPI', '1.11')) {
                        context.workbook.save(Excel.SaveBehavior.save);
                        console.log('supported');
                    } else {
                        console.log('not supported');
                    }
                })

我尝试了很多,但无法摆脱这个错误。我只是想知道是我做错了什么还是微软文档不正确。请帮忙。

标签: javascriptexceloffice-addins

解决方案


ExcelAPI', '1.5' 开始支持保存excel,回调函数尝试结束

return context.sync()

推荐阅读