如何使用Apache POI 3.6在Excel表中获取超过255列 [英] How to get more than 255 columns in an excel sheet using Apache POI 3.6
问题描述
这是我的代码:
int day_cell = 0; (int i = 0; i< days.size(); i ++)
{
Date day = days.get(i);
HSSFCell cell = row.createCell(day_cell ++);
cell.setCellValue(day.toString());
}
当我到列256 POI抛出这个异常:
java.lang.IllegalArgumentException:无效的列索引(256)。 BIFF8的允许列范围为(0..255)或('A'..'IV')
在org.apache.poi.hssf.usermodel.HSSFCell.checkBounds(HSSFCell.java:926)
(在org.apache.poi.hssf.usermodel.HSSFCell。 )
在org.apache.poi.hssf.usermodel.HSSFRow.createCell(HSSFRow.java:119)
我发现这个bug报告表明它已经在3.6版本中修复了。我们使用3.5,但变成3.6似乎没有任何好处。任何人都有任何提示?
https://issues.apache.org/bugzilla/show_bug.cgi?id=46806
编辑:似乎是关于公式的bug问题
我想出来了。我不得不从 org.apache.poi.hssf.usermodel 切换到 org.apache.poi.ss.usermodel
这允许您使用16k列或类似的列。
I'm creating a calendar in excel. Column 1 is 01.01.2010 (dd.MM.yyyy), Column 2 is 02.01.2010 and so on.
This is my code:
int day_cell = 0;
for(int i = 0; i < days.size(); i++)
{
Date day = days.get(i);
HSSFCell cell = row.createCell(day_cell++);
cell.setCellValue(day.toString());
}
When I get to column 256 POI throws this exception:
java.lang.IllegalArgumentException: Invalid column index (256). Allowable column range for BIFF8 is (0..255) or ('A'..'IV')
at org.apache.poi.hssf.usermodel.HSSFCell.checkBounds(HSSFCell.java:926)
at org.apache.poi.hssf.usermodel.HSSFCell.<init>(HSSFCell.java:162)
at org.apache.poi.hssf.usermodel.HSSFRow.createCell(HSSFRow.java:141)
at org.apache.poi.hssf.usermodel.HSSFRow.createCell(HSSFRow.java:119)
I found this bug-report suggesting it was fixed in the 3.6 release. We were using 3.5 but changing to 3.6 doesn't seem to do any good. Anyone got any tips?
https://issues.apache.org/bugzilla/show_bug.cgi?id=46806
Edit: Seems like the bug-issue was about formulas..
I figured it out. I had to switch from the org.apache.poi.hssf.usermodel to the org.apache.poi.ss.usermodel
This allows you to use 16k columns or something like that.
这篇关于如何使用Apache POI 3.6在Excel表中获取超过255列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!