PackageCom.hd.all.test.testjava;ImportJava.io.File;ImportJava.io.FileInputStream;Importjava.io.FileNotFoundException;Importjava.io.IOException;ImportOrg.apache.poi.hssf.usermodel.HSSFRow;ImportOrg.apache.poi.hssf.usermodel.HSSFSheet;ImportOrg.apache.poi.xssf.usermodel.XSSFRow;ImportOrg.apache.poi.xssf.usermodel.XSSFSheet;ImportOrg.apache.poi.xssf.usermodel.XSSFWorkbook; Public classReadexcelpoi { Public Static voidMain (string[] args)throwsFileNotFoundException, IOException {//students2017-10-19_11_22_52.xls--> This can also be read with the following code, because this file is generated by the object that the. xlsx should use, essentially. xlsxXssfworkbook Workbook =NewXssfworkbook (NewFileInputStream (NewFile ("E:/students2017-10-19_11_23_33.xlsx"))); Xssfsheet sheet= Workbook.getsheetat (0); Xssfrow Row= Sheet.getrow (0); System.out.println (Row.getcell (0));/*Hssfworkbook workbook = new Hssfworkbook (new FileInputStream (New File ("E:/students2017-10-19_10_55_55.xls")); Hssfsheet sheet = workbook.getsheetat (0); Hssfrow row = sheet.getrow (0); System.out.println (Row.getcell (0));*/ }}
Java reads Excel through POI