By parsing excel poi

1, add the appropriate jar package

2, using the following method:

Workbook = WorkbookFactory.create Workbook ( new new File ( "F: / Upload /" + fileName)); // Create the Workbook object to parse the corresponding Excel 
                Sheet sheet = workbook.getSheetAt (0 ); // find the index sheet through
                 int rownum = sheet.getLastRowNum (); // find the last line
                 for ( int I =. 1; I <= rownum; I ++ ) {// through each row 
                    row row = sheet.getRow (I); // row object obtained by data row 
                    Student Student = new new Student (); // data encapsulated by the student on the parsed
                    student.setName (row.getCell ( 0 ) .getStringCellValue ()); // Set the format corresponding to the acquired data 
                    student.setAge (( int ) row.getCell (. 1 ) .getNumericCellValue ()); 
                    student.setDate (Row .getCell ( 2 ) .getDateCellValue ()); 
                    studentList.add (Student);

Guess you like

Origin www.cnblogs.com/shouyaya/p/12088864.html