如何在 Excel 工作表中使用 Office-js 插入页眉和页脚
问题描述:
我们想使用 Office-js Api 在 Excel 工作表的页眉和页脚中插入文本.现在或不久的将来有什么方法可以做到这一点吗?
We want to insert text into headers and footers of an Excel Worksheet using the Office-js Api. Is there any way available now or in the near future to do this?
答
此功能在 ExcelApi 1.9(今年 5 月)中引入.文档
This feature got introduced in ExcelApi 1.9 (this May). Documentation
一些示例代码:
Excel.run(async (context)=>{
const sheets = context.workbook.worksheets;
sheets.load({$all: true}); // Load all sheets
const headerFooter = sheets.getActiveWorksheet().pageLayout.headersFooters.defaultForAllPages;
headerFooter.load({$all: true}); // Load header/footer
await context.sync();
headerFooter.set({leftHeader: 'something'});
});