name.xslx
1 public class Demo6 { 2 3 public static void main(String[] args) throws IOException { 4 InputStream is = new FileInputStream("F:\\poi\\name.xls"); 5 POIFSFileSystem fs = new POIFSFileSystem(is); 6 HSSFWorkbook wb = new HSSFWorkbook(fs); 7 HSSFSheet sheet = wb.getSheetAt(0);//获取第一个sheet页 8 if(sheet==null){ 9 return; 10 } 11 //遍历row 12 for(int rowNum = 0; rowNum<=sheet.getLastRowNum();rowNum++ ){ 13 HSSFRow row = sheet.getRow(rowNum); 14 if(row == null){ 15 continue; 16 } 17 //遍历cell 18 for (int cellNum = 0; cellNum < row.getLastCellNum(); cellNum++) { 19 HSSFCell cell = row.getCell(cellNum); 20 if(cell == null){ 21 continue; 22 } 23 System.out.println(" "); 24 } 25 System.out.println(); 26 } 27 } 28 29 private static String getValue(HSSFCell cell){ 30 String cellvalue = ""; 31 switch (cell.getCellType()){ 32 case HSSFCell.CELL_TYPE_NUMERIC: 33 cellvalue = String.valueOf(cell.getNumericCellValue()); 34 break; 35 case HSSFCell.CELL_TYPE_STRING: 36 cellvalue = String.valueOf(cell.getStringCellValue()); 37 break; 38 case HSSFCell.CELL_TYPE_BOOLEAN: 39 cellvalue = String.valueOf(cell.getBooleanCellValue()); 40 break; 41 case HSSFCell.CELL_TYPE_FORMULA: 42 cellvalue = String.valueOf(cell.getArrayFormulaRange()); 43 break; 44 default: 45 break; 46 } 47 return cellvalue; 48 } 49 }
Exception: at The Supplied to the Data BE in the Appears at The Office 2007+ . XML reason or excel2003 excel2007 version of the problem and the key issues of 3 , solutions to ( 1 ) determine the file extension is xls, or XLSX ( 2) If xls, use HSSFWorkbook; if it is xlsx, use XSSFWorkbook
Question: There are many versions excel resolve it? ? ? ?