阅读限制访问的excel文件:没有这样的条目:" EncryptionInfo",有:[EncryptedPackage,

时间:2017-11-01 04:15:42

标签: java excel apache-poi xlsx

如何阅读限制访问权限的Excel? 不要误以为密码保护的excel文件。我正在尝试创建一个java程序来读取一个文件,其中"完全控制"仅给予所有者和"我组织中的每个人"有读取权限。请参阅图片。

我可以在Windows中打开该文件,因为我是"我组织中的每个人" enter image description here

我试过了POI。



	Workbook workbook = null;
	try {
		workbook = WorkbookFactory.create(new File("D:/temp/table_export.xlsx"));
	} catch (EncryptedDocumentException e1) {
		log.error("unable to read excel file", e1);
		e1.printStackTrace();
		
	} catch (InvalidFormatException e1) {
		log.error("unable to read excel file", e1);
		e1.printStackTrace();
		
	} catch (IOException e) {
		System.err.println("IOException");
		e.printStackTrace();
	} catch (Exception e) {
		System.err.println("Exception");
		e.printStackTrace();
	}

	Sheet sheet;
	sheet = workbook.getSheetAt(0);
	log.info("SheetName:" + sheet.getSheetName());




它在" WorkbookFactory.create()"

中引发异常

java.io.FileNotFoundException:没有这样的条目:" EncryptionInfo",有:[EncryptedPackage,DocumentSummaryInformation,SummaryInformation,DataSpaces]     在org.apache.poi.poifs.filesystem.DirectoryNode.getEntry(DirectoryNode.java:399)     在org.apache.poi.poifs.filesystem.DirectoryNode.createDocumentInputStream(DirectoryNode.java:188)     在org.apache.poi.poifs.crypt.EncryptionInfo。(EncryptionInfo.java:102)     在org.apache.poi.poifs.crypt.EncryptionInfo。(EncryptionInfo.java:95)     在org.apache.poi.poifs.filesystem.DocumentFactoryHelper.getDecryptedStream(DocumentFactoryHelper.java:48)     在org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:87)     在org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:256)     在org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:226)     在org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:205)     在ExlTest.main(ExlTest.java:23) 线程" main"中的例外情况显示java.lang.NullPointerException     在ExlTest.main(ExlTest.java:41)

请建议一种解决方法。我甚至可以在代码中提供用户名/密码

0 个答案:

没有答案