0
点赞
收藏
分享

微信扫一扫

POi 读取word、Excel 里面的文本内容(注:JDK需要1.5以上)

云岭逸人 2023-05-12 阅读 76


POI 解析 Excel

File[] files = hFileEntity.getAttach();
is = new FileInputStream(files[0]);
Workbook wb = null;
try {
wb  = new XSSFWorkbook(files[0].getAbsolutePath());//解析excel2007以上的
} catch (Exception e) {
POIFSFileSystem fs = new POIFSFileSystem(is);//解析excel2003的
wb =  new HSSFWorkbook(fs);
}
Sheet rs = (Sheet) wb.getSheetAt(0);


rs.getLastRowNum()//从0开始计行数
Row firstRow = rs.getRow(0);
 firstRow.getLastCellNum()//从1开始计列数

举报

相关推荐

0 条评论