Java reader versions 03 and 07 EXCEL, java0307excel
Jxl. jar is required for excel version 03.
Package test. poi; import java. io. file; import java. io. IOException; import jxl. sheet; import jxl. workbook; import jxl. read. biff. biffException; // version 03 excelpublic class getExcel {public static void main (String [] args) {show03Excel ();} public static void show03Excel () {Sheet sheet; workbook book = null; try {book = Workbook. getWorkbook (new File ("F: \ Book1.xls");} catch (BiffException e) {e. printStackTrac E ();} catch (IOException e) {e. printStackTrace ();} // System. out. println (book); // obtain the first worksheet object (the sheet number in ecxel starts from 0 ,....) sheet = book. getSheet (0); int rows = 0; int r = 0, l = 0; String value = null; while (sheet. getCell (0, r ). getContents ()! = "" & Sheet. getCell (0, r). getContents ()! = Null) {r ++;} while (sheet. getCell (l, 0). getContents ()! = "" & Sheet. getCell (l, 0). getContents ()! = Null) {l ++;} for (int I = 0; I <(r); I ++) {for (int j = 0; j <(l ); j ++) System. out. print (sheet. getCell (j, I ). getContents () + "\ t"); System. out. println ();}}}
The jar package poi is required for EXCEL of Version 07.
Package test. poi; import java. io. IOException; import org. apache. poi. xssf. usermodel. XSSFRow; import org. apache. poi. xssf. usermodel. XSSFSheet; import org. apache. poi. xssf. usermodel. XSSFWorkbook; public class get07Excel {public static void main (String [] arg) {show07excel ();} public static void show07excel () {XSSFWorkbook xwb = null; try {xwb = new XSSFWorkbook ("F: \ Book1.xlsx");} catch (IOException e) {e. PrintStackTrace ();} XSSFSheet sheet = xwb. getSheetAt (0); XSSFRow row; String cell; int r = 0, l = 0; row = sheet. getRow (0); while (row. getCell (l ). toString ()! = "" & Row. getCell (l). toString ()! = Null) {l ++;} while (row. getCell (0). toString ()! = "" & Row. getCell (0). toString ()! = Null) {r ++; row = sheet. getRow (r);} System. out. println ("the rows is" + r + "and the number of one row is" + l); // cyclically output the table content for (int I = sheet. getFirstRowNum (); I <r; I ++) {row = sheet. getRow (I); for (int j = row. getFirstCellNum (); j <l; j ++) {cell = row. getCell (j ). toString (); System. out. print (cell + "\ t");} System. out. println ("");}}}