0

我有一个应该读取excelRow文件的代码,但是当我想实现时,我无法弄清楚类的类型是什么。

任何人?谢谢!而我只能是一个迭代器吗?没有前锋?

图片: 在此处输入图像描述

4

2 回答 2

2

正如Apache POI ChangeLog 解释的那样,POI 2.5.1 于 2004 年 2 月29日发布,到现在已经快 10 年了!你真的真的需要升级到这十年的一个版本......

您想要的类是org.apache.poi.ss.usermodel.Row,它在 POI 3.5 中完全引入。

我建议您升级到 POI 3.9 最终版,或者甚至更好的 POI 3.10 beta 2(撰写本文时的最新版本)。这将解决您缺少课程的问题,并提供数量惊人的错误修复,如更新日志中所述

此外,正如关于迭代行和单元格的 POI 文档中所解释的,您可以使用 for 循环,例如:

Sheet sheet = wb.getSheetAt(0);
for (Row row : sheet) {
  for (Cell cell : row) {
    // Do something here
  }
}
于 2013-09-19T13:06:44.947 回答
2

The iterator method which returns a org.apache.poi.ss.usermodel.Row was added into the library some time between versions 3.0.x and 3.7 and as such will not be available in version 2.5.1, you appear to be working with a library that is older than your code examples. You will Either need to upgrade the library (with any potential knock on effects), or code in the style that the older lib exposed these features.

于 2013-09-19T12:38:34.613 回答