SpreadsheetFormatRow 突然停止工作 [英] SpreadsheetFormatRow abruptly stops working

查看:20
本文介绍了SpreadsheetFormatRow 突然停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过

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

切换到使用 XML 格式

excelSheet = SpreadsheetNew("ReportName",true);

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

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

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

coldfusion.runtime.java.MethodSelectionException:找不到 getcustompalette 方法

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

或者更好,因为它适用于 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"变量="#SpreadSheetReadBinary(excelSheet)#">

I've seen this post, but there does look to be a resolution. Anyway, I'm using ColdFusion 10 to generate an Excel spreadsheet. However, when I use SpreadsheetFormatRow() and pass in the rows to be formatted, it only does about 3 and then abruptly stops. Here is an example...

ColdFusion Code

<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)#">

and here is a screenshot of the resulting Excel sheet

Why is the formatting stopping after X number of rows and cells? If I switch to using XML format with

excelSheet = SpreadsheetNew("ReportName",true);

it works properly. However I'm using a custom palette for my colors so I don't think switching to XLSX format is going to work for me. When I try and then call

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

I get an error stating that getCustomPalette() method is undefined.

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

Can anyone help me figure this out? Thank you!!!

Or even better since it works with the XML format, can anyone show example of how to use a custom palette with the XLSX (xml format)

解决方案

This is an issue I have seen often when dealing with xls files from CF; they seem to stop applying styles after a certain number of cells. I've been able to work around it by outputting to xlsx instead. (I was able to replicate and "fix" your issue by doing so.)

excelSheet = SpreadsheetNew("ReportName",true); 

...

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

这篇关于SpreadsheetFormatRow 突然停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆