是否有一种方法可以使用ColdFusion SpreadsheetSetHeader/ footer函数在页眉/页脚中添



我们有一个web应用程序,使用Adobe 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文档。

最新更新