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

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

问题描述

我看到过



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

  excelSheet = SpreadsheetNew(ReportName,true); 

它可以正常工作。然而,我使用一个自定义调色板为我的颜色,所以我不认为切换到XLSX格式将为我工作。当我尝试然后调用

  palette = excelSheet.getWorkbook()。getCustomPalette 

我得到一个错误,说明getCustomPalette()方法未定义。

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

任何人都可以帮我找出这个?谢谢!!!



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

解决方案

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

  excelSheet = SpreadsheetNew(ReportName,true ); 

...

 < cfheader name =Content-Dispositionvalue =inline; filename = reportName.xlsx> 
< cfcontent type =application / vnd.openxmlformats-officedocument.spreadsheetml.sheet
variable =#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天全站免登陆