本文介绍了如何解决小号preadSheetAddRows功能加入大量查询时崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

EDIT3:由于@Leigh的帮助下我已经缩小的问题在查询日期列。使用原来的$ C $账套和POI,当s preadSheetAddRows()尝试添加包含日期样细胞非常大的查询页面崩溃。我在这里做了一个错误报告:


我有我加入,似乎当查询行的unweil​​dly量(18583在这个例子中)误差A S preadhseet对象的查询。确切的错误是:

  java.lang.ArrayIndexOutOfBoundsException:-32735
在java.util.ArrayList.get(ArrayList.java:324)
在org.apache.poi.hssf.model.WorkbookRecordList.get(WorkbookRecordList.j AVA:50)
在org.apache.poi.hssf.model.Workbook.getExFormatAt(Workbook.java:787)
在org.apache.poi.hssf.usermodel.HSSFCell.getCellStyle(HSSFCell.java:901)
在org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java:1727)
在coldfusion.excel.Excel.autoResize(Excel.java:1246)
在coldfusion.excel.Excel.autoResize(Excel.java:1240)
在coldfusion.excel.Excel.addRows(Excel.java:1214)
在coldfusion.runtime.CFPage.S preadSheetAddRows(CFPage.java:7089)在coldfusion.runtime.CFPage.S preadSheetAddRows(CFPage.java:7076)

下面是有关的code:

 < CFSET XLS = S preadsheetNew()>
< CFSET US preadsheetAddRow(XLS,arrayToList(qryTest.getMeta()getColumnLabels()))>
< CFSET US preadsheetFormatRow(XLS,{大胆= TRUE,fgcolor =棕色,颜色=白色},1)>
< CFSET US preadsheetAddRows(XLS,打开qryTest)GT;
< cfheader名=内容处置VALUE =附件;文件名=##文件名>
< cfcontent变量=#小号preadsheetReadBinary(XLS)#复位=是TYPE =应用程序/ vnd.ms - Excel的>


编辑:(它也有需要创建一个临时文件服务的缺点)我没有使用CFS preadsheet previously成功,但它不会产生与头preadsheet


EDIT2:继@Leigh建议我在CF9 / lib文件夹更新POI。现在错误已经更改为以下内容:

< CFSET US preadsheetFormatRow(XLS,{大胆= TRUE,fgcolor =棕色,颜色=白色},1)> 给出以下消息:org.apache.poi.hssf.util.HSSFColor.getIndexHash()Ljava / UTIL /哈希表;

错误code:

  java.lang.NoSuchMethodError:
org.apache.poi.hssf.util.HSSFColor.getIndexHash()Ljava / UTIL /哈希表;
在coldfusion.excel.Excel.getHSSFColor(Excel.java:2094)
在coldfusion.excel.Excel.findFont(Excel.java:2237)
在coldfusion.excel.Excel.getCellStyle(Excel.java:2318)
在coldfusion.excel.Excel.formatRow(Excel.java:2948)
在coldfusion.excel.Excel.formatRow(Excel.java:2963)
在coldfusion.excel.Excel.formatRow(Excel.java:2981)
在coldfusion.runtime.CFPage.S preadSheetFormatRow(CFPage.java:7268)

在谈到这一行了,现在再次崩溃于:
< CFSET US preadsheetAddRows(XLS,打开qryTest)GT;

错误code:

  java.lang.IllegalStateException:超出的单元格样式的最大数量。您可以在.xls的工作簿中定义多达4000个款式
在org.apache.poi.hssf.usermodel.HSSFWorkbook.createCellStyle(HSSFWorkbook.java:1120)
在org.apache.poi.hssf.usermodel.HSSFWorkbook.createCellStyle(HSSFWorkbook.java:73)
在coldfusion.excel.Excel.addRow(Excel.java:1323)
在coldfusion.excel.Excel.addRows(Excel.java:1203)
在coldfusion.runtime.CFPage.S preadSheetAddRows(CFPage.java:7089)
在coldfusion.runtime.CFPage.S preadSheetAddRows(CFPage.java:7076)


解决方案

我怀疑它无关,与CF或JRE版本都没有。至少没有直接。这听起来像POI的错误。

如果你看一下例外它清楚地表明了问题发生在CF调用试图自动调整列(添加查询数据之后)POI方法。快速搜索打开了类似 ArrayIndexOutOfBoundsException异常错误的几份报告与 HSSFSheet.autoSizeColumn (这恰好提的ColdFusion):

According to the bug report the issue existed in version 3.5, which is the same (major) version included with ColdFusion 9. One of the POI developers suggests the issue was fixed in later versions. So you might try updating the POI jar. Aside from that, if you can put together a test case that reproduces the issue, you may want to file a bug report.

cfspreadsheet probably does not attempt to automatically resize the columns like spreadsheetAddRows does, hence no error occurs. So the obvious workaround (and not a great one) is to avoid functions that attempt to resize the column widths.

这篇关于如何解决小号preadSheetAddRows功能加入大量查询时崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 13:36
查看更多