如何使用Apache POI 3.6在Excel表中获取超过255列 [英] How to get more than 255 columns in an excel sheet using Apache POI 3.6

查看:663
本文介绍了如何使用Apache POI 3.6在Excel表中获取超过255列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个excel中的日历。第1列为01.01.2010(dd.MM.yyyy),第2列为02.01.2010等。



这是我的代码:

  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屋!

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