POI解析Excel文件

时间:2024-08-29 19:38:14

@Test

public void test1() throws FileNotFoundException, IOException{

HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(new File("d:\\abc.xls")));

HSSFSheet sheet = workbook.getSheetAt(0);

for (Row row : sheet) {

String v1 = row.getCell(0).getStringCellValue();

String v2 = row.getCell(1).getStringCellValue();

String v3 = row.getCell(2).getStringCellValue();

String v4 = row.getCell(3).getStringCellValue();

String v5 = row.getCell(4).getStringCellValue();

System.out.println(v1 + " " + v2+" " + v3+ " " +v4+ " " + v5);

}

}