excel - 有没有办法使用 ColdFusion SpreadsheetSetHeader/Footer 函数在页眉/页脚中添加 Excel 页码

标签 excel coldfusion cfspreadsheet

我们有一个 Web 应用程序,它使用 Adob​​e ColdFusion 电子表格函数将报告导出到 Excel,其中两个函数是 SpreadsheetSetHeader 和 SpreadsheetSetFooter。有没有人想出如何使用这些函数嵌入 excel 文件的页码?

在 Excel 中,如果您转到页眉/页脚,您可以放置​​ &[PAGE] 以在打印时插入页码,但我还没有找到在 ColdFusion 中执行此操作的方法。

最佳答案

POI 是 CF 在底层用于生成电子表格的工具。 POI 有自己的格式代码,但它们是相似的。在页脚字符串中使用 &P(当前页)和 &N(总页数)。

<cfscript>

  // Create demo spreadsheet
  sheet = SpreadsheetNew("Sheet1", true);
  sheet.setCellValue("Test", 1,1);

  // Add footer with page numbers
  sheet.setFooter("", "&P of &N", "");

  // Download
  cfheader(name="Content-Disposition",value="attachment; filename=Sheet.xlsx"); 
  cfcontent(type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
      , variable="#SpreadsheetReadBinary( sheet )#");
</cfscript>

有关格式化代码的更多信息,请参阅 POI 的 XSSHeaderFooter 文档.

关于excel - 有没有办法使用 ColdFusion SpreadsheetSetHeader/Footer 函数在页眉/页脚中添加 Excel 页码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68660442/

相关文章:

coldfusion - 如何在Excel工作表中显示完整的数字?

excel - 在 Outlook 电子邮件中粘贴 Excel 表格 : it looks back

vba - 如何将 Selenium 添加到 Excel VBA 2013?

ColdFusion 循环条件属性

pdf - ColdFusion CFPDFFORM 不会填充 PDF 表单字段

coldfusion - 如何用Coldfusion 10处理超大xls文件

javascript - alasql导出的excel公式不起作用

vba - 保护非空单元格VBA

coldfusion - 正确使用 cflock 标签 ColdFusion

mysql - ColdFusion10 - 通过插入查询查询 cfloop