解決高版本Excel另存爲97-2003的xls,讀取失敗的問題

解決高版本加密Excel文件(XLSX)另存爲97-2003的xls,poi讀取失敗的問題 java

public static void main(String[] args) {
        try {
            decryptExcel_xlsx1();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void decryptExcel_xlsx1() throws IOException {
        Workbook wb = null;
        FileInputStream in = null;
        try {
            in = new FileInputStream("xxx.xls");//讀取xlsx文件
            wb = WorkbookFactory.create(in,password);//設置密碼打開
        } catch (Exception e) { e.printStackTrace();
        }finally { in.close();
        } System.out.println("=================================");
        System.out.println("Number of Sheets:" + wb.getNumberOfSheets());
        System.out.println("Sheet3's name:" + wb.getSheetName(0));
        System.out.println();
    }

<dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>3.17</version>
    </dependency>
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi-ooxml</artifactId>
      <version>3.17</version>
    </dependency>
相關文章
相關標籤/搜索