read the specified data import column poi

Uploading ResponseResult public (a MultipartFile file1) throws IOException { 
String filename = file1.getOriginalFilename ();
// read the file stream 1.
FileInputStream stream = new FileInputStream ( "C : \\ Users \\ admin \\ Desktop \\ sss \\ "+ filename);

// 2. Excel file object obtained by parsing streams poi
HSSFWorkbook Workbook = new new HSSFWorkbook (stream);

// 3. acquired by the object data table obtained
HSSFSheet sheet workbook.getSheetAt = (0);

HSSFRow Row = null ;

for (int I = 0;! sheet.getRow (I) = null; I ++) {

Row = sheet.getRow (I);
SystemParam System new new SystemParam = ();
for (int J = 0; row.getCell (J !) = null; J ++) {
// of System.out.print (row.getCell (J) .toString () + "");

IF (J == 0) {
// System.out.print(row.getCell(0).getStringCellValue());
// System.out.println();
system.setName(row.getCell(0).getStringCellValue());
}else if (j==2){
system.setValues("lv_"+row.getCell(2).getStringCellValue());
// System.out.print("lv_"+row.getCell(2).getStringCellValue());
// System.out.println();
}

}
System.out.println(system);
}
return ResponseResult.okMsg("提交成功");
}

Guess you like

Origin www.cnblogs.com/zhaohuihui/p/11818366.html