Issue while reading Excel document (Java code)

后端 未结 3 810
深忆病人
深忆病人 2020-12-22 10:45

I have some Java code which reads the Excel data. On running the Java code, it\'s showing the following error. Help me resolve the same. Also, I need to know other method of

3条回答
  •  有刺的猬
    2020-12-22 11:12

    you are using the wrong class for reading the file HSSFWorkbook is for old excel format. use XSSFWorkbook instead

    Edited: copied from http://www.coderanch.com/t/463779/java/java/read-xlsx-sheet-Client-Side. did u do the same thing?

    try { 
    System.out.println("destDir==> "+destDir); 
    XSSFWorkbook workBook = new XSSFWorkbook(destDir); 
    XSSFSheet sheet = workBook.getSheetAt(0); 
    totalRows = sheet.getPhysicalNumberOfRows(); 
    System.out.println("total no of rows >>>>"+totalRows); 
    
    } catch (IOException e) { 
    e.printStackTrace(); 
    } 
    

    Edit 2: Learn about apache POI from this link

提交回复
热议问题