解决高版本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>
相关文章
相关标签/搜索