如何使用Apache POI 3.6来获得在一个Excel工作表超过255列 [英] How to get more than 255 columns in an excel sheet using Apache POI 3.6

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

问题描述

我创建Excel中的一个日历。塔1是01.01.2010(DD.MM.YYYY),第2列是2010年2月1日等。

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.

这是我的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());
}

当我到达256列POI抛出此异常:

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)

我发现这个错误报告表明它是固定在3.6版本。我们使用3.5但改变至3.6似乎并没有什么好处。任何人有什么秘诀?

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?

<一个href=\"https://issues.apache.org/bugzilla/show_bug.cgi?id=46806\">https://issues.apache.org/bugzilla/show_bug.cgi?id=46806

编辑:似乎是一个bug的问题是有关公式。

Seems like the bug-issue was about formulas..

推荐答案

我想通了。我不得不切换 org.apache.poi.hssf.usermodel org.apache.poi.ss.usermodel

I figured it out. I had to switch from the org.apache.poi.hssf.usermodel to the org.apache.poi.ss.usermodel

这允许你使用16K列或类似的东西。

This allows you to use 16k columns or something like that.

这篇关于如何使用Apache POI 3.6来获得在一个Excel工作表超过255列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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