81,116
社区成员




private static void read(InputStream inputStream)throws Exception{
HSSFWorkbook workbook = new HSSFWorkbook(inputStream);
for (int sheetindex = 0; sheetindex < workbook.getNumberOfSheets(); sheetindex++) {
HSSFSheet sheet = workbook.getSheetAt(sheetindex);
for (int rowindex = 0; rowindex < sheet.getLastRowNum(); rowindex++) {
HSSFRow row = sheet.getRow(rowindex);
if(null == row)
continue;
for (int cellindex = 0; cellindex < row.getLastCellNum(); cellindex++) {
HSSFCell cell = row.getCell(cellindex);
System.out.print(cell.getRichStringCellValue().getString()+"\t");
}
System.out.println();
}
}
}
public static void main(String[] args) {
InputStream inputStream = null;
try {
inputStream = new FileInputStream(new File("d:\\test.xlsx"));
POIForExcel.read(inputStream);
} catch (Exception e) {
// TODO: handle exception
}finally{
try {
inputStream.close();
} catch (Exception e2) {
// TODO: handle exception
}
}
}
for (int rowindex = 0; rowindex <=sheet.getLastRowNum(); rowindex++) {