Excel文件读取
java中要读取excel文件并解析。目前的excel文件主要是xls的97-2000格式和xlsx的2007格式。
以下提供简单的操作示例。
?
1,workbook
解析文件格式:xls
?
xssfworkbook xwb = new xssfworkbook(in);// 读取第一章表格内容 xssfsheet sheet = xwb.getsheetat(0); xssfrow row;for(int i=sheet.getfirstrownum()+1;i<sheet.getlastrownum()+1;i++){row = sheet.getrow(i);system.out.print(row.getcell(0).tostring()+";");system.out.print(row.getcell(1).tostring()+";");system.out.print(row.getcell(2).tostring()+";");system.out.print(row.getcell(3).tostring()+";");system.out.print(row.getcell(4).tostring());system.out.println();}} catch (ioexception e) {e.printstacktrace();} ?