转自 http://topic.csdn.net/u/20110325/13/28347120-5632-4b31-8f23-eeea6672ce23.html
JDK版本:jdk-6u14-windows-i586.exe
POI版本:poi-bin-3.7-20101029.zip
错误信息:
java.lang.ArrayIndexOutOfBoundsException: -32735
at java.util.ArrayList.get(ArrayList.java:324)
at org.apache.poi.hssf.model.WorkbookRecordList.get(WorkbookRecordList.java:50)
at org.apache.poi.hssf.model.InternalWorkbook.getExFormatAt(InternalWorkbook.java:826)
at org.apache.poi.hssf.usermodel.HSSFCell.<init>(HSSFCell.java:198)
at org.apache.poi.hssf.usermodel.HSSFRow.createCellFromRecord(HSSFRow.java:204)
at org.apache.poi.hssf.usermodel.HSSFSheet.setPropertiesFromSheet(HSSFSheet.java:184)
at org.apache.poi.hssf.usermodel.HSSFSheet.<init>(HSSFSheet.java:121)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:275)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:188)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:170)
at com.sumavision.common.util.ExcelPOI.getExcleRows(ExcelPOI.java:45)
at com.sumavision.common.util.ExcelPOI.main(ExcelPOI.java:18)
源码:ExcelPOI .java
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
public class ExcelPOI {
public static void main(String[] args) {
try {
int count = ExcelPOI.getExcleRows("D:/2011.03.14-24.xls",0);
System.out.println("count="+count);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Excle某个工作簿所有行数
*
* @param filePath
* Excel文件路径
* @param index
* 第一张工作表的索引是0
* @return int
* @throws FileNotFoundException
* @throws IOException
*/
public static int getExcleRows(String filePath, int index)
throws FileNotFoundException, IOException {
// 创建对Excel工作簿文件的引用
POIFSFileSystem fs =
new POIFSFileSystem(new FileInputStream(filePath));
HSSFWorkbook workbook = new HSSFWorkbook(fs);
// 在Excel文档中,第一张工作表的缺省索引是0
// 其语句为:
HSSFSheet sheet = workbook.getSheetAt(index);
// HSSFSheet sheet = workbook.getSheet("Sheet1");
// 获取到Excel文件中的所有行数
return sheet.getPhysicalNumberOfRows();
}
}
分享到:
相关推荐
内部包括poi-3.8-20120326.jar、poi-ooxml-3.8-20120326.jar、poi-ooxml-schemas-3.8-20120326.jar 测试可用版本,有些下载的不能用
java中读取word文档需要引用apache的poi开源项目包; 官方下载地址:http://poi.apache.org/download.html 为方便下载提供6个jar包,其中包含:poi-3.8.jar;poi-ooxml-3.8.jar;poi-ooxml-schemas-3.8.jar;poi-...
用户poi开发,将excel中的数据导入到数据库中所用的jar包。poi-3.8-20120326.jar 和 poi-excelant-3.8-20120326.jar
org.apache.poi:poi:4.1.2 org.apache.poi:poi-ooxml:4.1.2 org.apache.poi:poi-ooxml-schemas:4.1.2 org.apache.xmlbeans:xmlbeans:3.1.0 com.github.virtuald:curvesapi:1.06 com.zaxxer:SparseBitSet:1.2 commons...
导入excel需要的\poi-ooxml-schemas-3.8-20120326.jar
poi-jar包:poi-3.8.jar、poi-3.9.jar、poi-3.16.jar、poi-ooxml-3.9.jar、poi-ooxml-3.16.jar、poi-scratchpad-3.9.jar
包含poi-3.7-20101029.jar,poi-examples-3.7-20101029.jar,poi-ooxml-3.7-20101029.jar,poi-ooxml-schemas-3.7-20101029.jar,poi-scratchpad-3.7-20101029.jar,xmlbeans-2.3.0.jar,dom4j-1.6.1.jar,可上传excel2003...
(2)有时,一套Java组件会有多个jar,所以在下载前,请仔细阅读本篇描述,以确保这就是你需要的文件; # Maven依赖: ``` <groupId>org.apache.poi <artifactId>poi-ooxml *** ``` # Gradle依赖: ``` ...
java开发中操作excle的jar包,功能齐全,很强大,非常实用。
poi-3.8-20120326-6个jar包: poi-3.8-20120326.jar poi-examples-3.8-20120326.jar poi-excelant-3.8-20120326.jar poi-ooxml-3.8-20120326.jar poi-ooxml-schemas-3.8-20120326.jar poi-scratchpad-3.8-20120326....
导入excel需要的poi-ooxml-3.8-20120326.jar
该jar包解决报错java.lang.NoClassDefFoundError: org/apache/james/mime4j/MimeException,亲测可用。
org.apache.poi.xwpf.converter.core-1.0.6org.apache.poi.xwpf.converter.core-1.0.6org.apache.poi.xwpf.converter.core-1.0.6org.apache.poi.xwpf.converter.core-1.0.6
org.apache.poi.xwpf.converter.pdf-1.0.6.jar 文件 org.apache.poi.xwpf.converter.pdf-1.0.6 org.apache.poi.xwpf.converter.core-1.0.6 org.apache.poi.xwpf.converter-0.9.1
poi-3.17 对work、excel操作,包含有: poi-3.17.jar poi-ooxml-3.17.jar poi-scratchpad-3.17.jar poi-ooxml-schemas-3.17.jar commons-codec-1.10.jar commons-collections4-4.1.jar commons-logging-1.2.jar ...
poi操作excel所需jar包及poi源码 包含内容 poi-3.7.jar poi-ooxml-3.7.jar poi-ooxml-schemas-3.7.jar poi-scratchpad-3.7.jar Lib-->commons-logging-1.1.jar lib-->junit-3.8.1.jar lib-->log4j.1.2.13.jar ooxml-...
org.apache.poi.xwpf.converter.pdf-1.0.6 org.apache.poi.xwpf.converter.core-1.0.6 org.apache.poi.xwpf.converter-0.9.1
XDocReport 操作word、pdf、jpg、png依赖包,org.apache.poi.xwpf.converter.pdf-1.0.6.jar
解决在Linux系统下,POI、easyExcel 报错 java.lang.IllegalArgumentException: The workbook already contains a sheet named。原因是缺少了字体文件,如果是Docker部署使用本资源即可。内部提供字体资源以及代码...
POI-3.7+3.8的jar包 ,亲测可用111111111111111111111111