coldfusion - SpreadsheetFormatRow 突然停止工作

标签 coldfusion spreadsheet coldfusion-10 cfspreadsheet

我看过 this发布,但看起来确实有一个解决方案。无论如何,我正在使用 ColdFusion 10 生成 Excel 电子表格。但是,当我使用 SpreadsheetFormatRow() 并传入要格式化的行时,它只执行大约 3 次然后突然停止。这是一个例子...

ColdFusion 代码

<cfscript>

    rowCount = 1;
    headingRows = 4;

    // Create instance of new Spreadsheet
    excelSheet = SpreadsheetNew("ReportName",false); 

    // HEADING (IMAGE) ROW FORMAT
    formatHeadingRow = StructNew();
    formatHeadingRow.fgcolor="blue";        

    // Add rows to fill the header area (must add as many as we are spanning with the above image)
    for (x=0;x<headingRows;x++) {
        SpreadsheetAddRow(excelSheet,"TEST,TEST,TEST,TEST,TEST,TEST,TEST,TEST,TEST,TEST,TEST,TEST");
        SpreadsheetFormatRow(excelSheet,formatHeadingRow,rowCount);
        rowCount++;
    }

</cfscript>

<!--- stream it to the browser --->
<cfheader name="Content-Disposition" value="inline; filename=reportName.xls">
<cfcontent type="application/vnd.ms-excel" variable="#SpreadSheetReadBinary(excelSheet)#">

这是生成的 Excel 工作表的屏幕截图

enter image description here

为什么格式化在 X 行和单元格后停止? 如果我切换到使用 XML 格式和

excelSheet = SpreadsheetNew("ReportName",true);

它正常工作。但是我为我的颜色使用了自定义调色板,所以我认为切换到 XLSX 格式对我来说不起作用。当我尝试然后调用

palette = excelSheet.getWorkbook().getCustomPalette();

我收到一条错误消息,指出 getCustomPalette() 方法未定义。

coldfusion.runtime.java.MethodSelectionException: The getcustompalette method was not found

谁能帮我解决这个问题?谢谢!!!

或者更好,因为它适用于 XML 格式,任何人都可以展示如何使用 XLSX(xml 格式)的自定义调色板的示例

最佳答案

这是我在处理来自 CF 的 xls 文件时经常看到的问题;他们似乎在一定数量的单元格后停止应用样式。我已经能够通过输出到 xlsx 来解决它。 (通过这样做,我能够复制并“解决”您的问题。)

excelSheet = SpreadsheetNew("ReportName",true); 

...

<cfheader name="Content-Disposition" value="inline; filename=reportName.xlsx">
<cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        variable="#SpreadSheetReadBinary(excelSheet)#">

关于coldfusion - SpreadsheetFormatRow 突然停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37817997/

相关文章:

java - 将来自 Android 应用程序的输入发送到 Google 文档电子表格

java - 如何强制 CFHTTP 不对查询参数进行编码?

coldfusion - 如何找出计划任务的下一次运行时间?

java - 我将如何在 ColdFusion(或 Java)中实现这个正则表达式?

google-apps-script - 如何比较谷歌应用程序脚本中的字符串

google-sheets - 对整个列执行 Google 电子表格查询

java - getMetaData() 抛出内部 NullPointerException

coldfusion - 如何修复 cfspreadsheet 中存储为文本的数字

coldfusion - 使用 buildURL 的路径信息过多

java - 使用 coldfusion 或 java 压缩文件的最有效方法