//*
*简单的excel读取
* @param inputFile
* @param inputFileSheetIndex
* @throws Exception
*/
publicstaticarraylistsamplereadexcel (文件输入文件,int inputFileSheetIndex ) throws Exception { ) )。
ArrayList list=new ArrayList (;
工作簿=空;
小区=空;
//避免乱码的设定
workbooksettingssetting=newworkbooksettings (;
Java.util.locale locale=new Java.util.locale (' zh ',' CN ' );
setting.setlocale(locale );
setting.setencoding(iso-8859-1 );
book=workbook.get workbook (input file,setting );
sheet sheet=book.get sheet (inputfilesheetindex;
for(introwindex=0; rowIndex sheet.getRows (; rowindex(/excel的第一行是标题,因此j的初始值被设置为1
for(intcolindex=0; colIndex sheet.getColumns (; colindex(//excel中只取出2列
cell=sheet.getcell(Colindex,rowIndex );
list.add(cell.getcontents ) );
}
}
//【问题】如果在实际部署时不写下一句话,会不断消耗服务器的内存吗? jxl中有ReadWrite.java关闭后没有读的东西。 只合上了写的东西】
book.close (;
返回列表;
}
共享至:
2008-04-23 16:46
参照4129
论坛回复/陟览(1/3101 ) )。
注释
一楼
吉延良
2008-04-23
将所有数据读入存储器。 如果数据量太大,肯定会变得暴力
请看调用的代码。