Setting Different Headers and Footers For Different Pages with Node.js via C++
Contents
[
Hide
]
MS Excel supports setting different headers and footers for the first page, odd pages, and even pages since Excel 2007.
Aspose.Cells for Node.js via C++ supports the same feature.
Setting Different Headers and Footers in MS Excel
- Click page Layout > Print Titles > Header/Footer.
- Check Different Odd and Even Pages or Different first page.
- Enter different headers and footers.
Setting Different Headers and Footers with Aspose.Cells for Node.js via C++
Aspose.Cells behaves the same as Excel.
- Sets the flags PageSetup.isHFDiffOddEven() and PageSetup.isHFDiffFirst()
- Enter different headers and footers.
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.");