用 Node.js 和 C++ 为不同页面设置不同的页眉和页脚
Contents
[
Hide
]
自Excel 2007起,MS Excel支持为首页、奇数页和偶数页设置不同的页眉和页脚。
Aspose.Cells for Node.js via C++支持相同的功能。
在MS Excel中设置不同的页眉和页脚
- 单击页面布局 > 打印标题 > 页眉/页脚。
- 检查 不同奇数和偶数页面 或 首页不同。
- 输入不同的页眉和页脚。
使用 Aspose.Cells for Node.js via C++ 设置不同的页眉和页脚
Aspose.Cells与Excel的行为相同。
- 设置标志 PageSetup.isHFDiffOddEven() 和 PageSetup.isHFDiffFirst()
- 输入不同的页眉和页脚。
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sample.xlsx");
// Loads the workbook which contains hidden external links
const wb = new AsposeCells.Workbook(filePath);
// Gets the setting of page setup.
const pageSetup = wb.getWorksheets().get(0).getPageSetup();
// Sets different odd and even pages
pageSetup.setIsHFDiffOddEven(true);
pageSetup.setHeader(1, "I am the header of the Odd page.");
pageSetup.setEvenHeader(1, "I am the header of the Even page.");
// Sets different first page
pageSetup.setIsHFDiffFirst(true);
pageSetup.setFirstPageHeader(1, "I am the header of the First page.");