使用POI讀取EXCEL中的所有Sheet表
阿新 • • 發佈:2019-01-09
{
HSSFWorkbook workbook=new HSSFWorkbook(new FileInputStream(new File("/file/student.xls")));
HSSFSheet sheet=null;
for (int i =0; i < workbook.getNumberOfSheets(); i++) {//獲取每個Sheet表
sheet=workbook.getSheetAt(i);
for (int j =0; j < sheet.getPhysicalNumberOfRows(); j ++) {//獲取每行
HSSFRow row=sheet.getRow(j);
for (int k =0; k < row.getPhysicalNumberOfCells(); k++) {//獲取每個單元格
System.out.print(row.getCell(k)+"\t");
}
System.out.println("---Sheet表"+i+"處理完畢---");
}
}
}
HSSFWorkbook workbook=new HSSFWorkbook(new FileInputStream(new File("/file/student.xls")));
HSSFSheet sheet=null;
for (int i =0; i < workbook.getNumberOfSheets(); i++) {//獲取每個Sheet表
sheet=workbook.getSheetAt(i);
for (int j =0; j < sheet.getPhysicalNumberOfRows(); j
HSSFRow row=sheet.getRow(j);
for (int k =0; k < row.getPhysicalNumberOfCells(); k++) {//獲取每個單元格
System.out.print(row.getCell(k)+"\t");
}
System.out.println("---Sheet表"+i+"處理完畢---");
}
}
}