Java用POI解析excel并获取所有单元格数据的实例
1.导入POI相关jar包
org.apache.poijar
2.代码示例
publicListgetAllExcel(Filefile,StringtableName,Stringfname,
StringenterpriseId,StringreportId,StringprojectId)
throwsFileNotFoundException,IOException,ClassNotFoundException,
InstantiationException,IllegalAccessException,
NoSuchMethodException,SecurityException,IllegalArgumentException,
InvocationTargetException,ParseException{
Listlistt=newArrayList();
try{
FileInputStreamfis=newFileInputStream(file);
Workbookworkbook=null;
if(fname.toLowerCase().endsWith("xlsx")){
workbook=newXSSFWorkbook(fis);
}elseif(fname.toLowerCase().endsWith("xls")){
workbook=newHSSFWorkbook(newPOIFSFileSystem(fis));
}
intnumberOfSheets=workbook.getNumberOfSheets();
for(inti=0;i
以上这篇Java用POI解析excel并获取所有单元格数据的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。