用 Node.js 和 C++ 为不同页面设置不同的页眉和页脚

在MS Excel中设置不同的页眉和页脚

设置不同的页眉和页脚

  1. 单击页面布局 > 打印标题 > 页眉/页脚
  2. 检查 不同奇数和偶数页面首页不同
  3. 输入不同的页眉和页脚。

使用 Aspose.Cells for Node.js via C++ 设置不同的页眉和页脚

Aspose.Cells与Excel的行为相同。

  1. 设置标志 PageSetup.isHFDiffOddEven()PageSetup.isHFDiffFirst()
  2. 输入不同的页眉和页脚。
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.");