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

阅读 76

2023-05-12


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)

0 0 举报