最近一直在逛博客园,难得周末有时间,就把最近一直想学习的java读写excel研究了下。
网上主要有两种方式对excel进行读写。
一种是采用POI.JAR包的方式。
源码在附近上
还有另外一种是jxl.jar包的方式进行读写。以下是读取时需要注意的地方吧,不过运行一遍就能看出规律来了。
System.out.println("rows"+st.getRows()); System.out.println("cell"+st.getColumns()); for(int row=0;row<st.getRows();row++){ for(int column=0;column<st.getColumns();column++){ Cell cell = st.getCell(column, row); String str = cell.getContents(); //获得cell具体类型值的方式 if(cell.getType() == CellType.LABEL) { LabelCell labelc00 = (LabelCell)cell; str = labelc00.getString(); } System.out.println("值:"+str); } }
由于不知道如何导入文件,源码放在CSDN上http://download.csdn.net/detail/a331251021/4587522
转载请加上http://www.cnblogs.com/zhengchubin/