一个EncryptedDocumentException信号,你正在尝试处理先前没有“解锁”的加密文档。以下代码段适合检查基于XML的格式(.xlsx,.pptx,.docx等)是否适用,以便以后可以安全地对其进行处理:String password = "secret"; // set passwordFile fileToProcess; // obtain/read/open the file here....NPOIFSFileSystem filesystem = new NPOIFSFileSystem(fileToProcess);EncryptionInfo info = new EncryptionInfo(filesystem);Decryptor d = Decryptor.getInstance(info);try { if (!d.verifyPassword(password)) { throw new RuntimeException("Unable to process: document is encrypted"); } InputStream dataStream = d.getDataStream(filesystem); // parse dataStream as the document is now processable from here on // ...} catch (GeneralSecurityException ex) { throw new RuntimeException("Unable to process encrypted document", ex);}上面的示例摘自官方POI文档的加密部分,并根据项目的JavaDoc进行了修改。您可能要检查/阅读类Decryptor和/或的JavaDoc NPOIFSFileSystem。如果要转换二进制文件格式(.xls,.ppt,.doc等),请查看加密部分以获取代码示例。