您好,
请参考附件demo,主要代码如下:
- document.getElementById('exportImgs').onclick = () => {
- sheet = spread.getActiveSheet();
- // 获取sheet原打印设置,便于后面恢复
- var oldPrintInfo = sheet.printInfo();
- var oldPrintArea = sheet.getCustomName("Print_Area") && GC.Spread.Sheets.CalcEngine.expressionToFormula(sheet, sheet.getCustomName("Print_Area").getExpression());
- console.log("原打印设置", oldPrintInfo);
-
- setPrintInfo(sheet);
- spread.print();
-
- // 恢复原sheet的打印设置,以避免影响打印/导出pdf行为
- sheet.printInfo(oldPrintInfo);
- sheet.removeCustomName("Print_Area");
- if (oldPrintArea) {
- sheet.addCustomName("Print_Area", oldPrintArea)
- }
- console.log("恢复后的打印设置:", sheet.printInfo());
- designer.refresh();
- }
复制代码 |
|