我正在使用下面的代码。
File pt_file_obj = new File("file.xlsm");
FileInputStream pt_inp_strm_obj = new FileInputStream(pt_file_obj);
POIFSFileSystem poi_fs = new POIFSFileSystem(pt_inp_strm_obj);
EncryptionInfo info = new EncryptionInfo(poi_fs);
Decryptor d = Decryptor.getInstance(info);
if(!d.verifyPassword("mypassword")) {
System.out.println("Incorrect password!");
}
Workbook wb = WorkbookFactory.create(d.getDataStream(poi_fs));
我在线收到运行时错误POIFSFileSystem poi_fs = new POIFSFileSystem(pt_inp_strm_obj);
我不明白我在做什么错...
Exception in thread "main" org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)
at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:128)
at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:112)
at org.apache.poi.poifs.filesystem.NPOIFSFileSystem.<init>(NPOIFSFileSystem.java:300)
at ptaccess.PTAccess.main(PTAccess.java:20)
Java Result: 1