使用ExcelDataReader和Epplus访问受保护的Excel文件
标题几乎说明了一切.寻找一种使用ExcelDataReader和Epplus访问受密码保护的excel文件的方法,找不到正确的答案.
title pretty much says it all. Looking for a way to access a password protected excel file with ExcelDataReader and Epplus, can't find a proper answer.
如果使用ExcelDataReader,我的代码如下
If using ExcelDataReader, my code looks like
excelStream = File.Open(excelFilePath, FileMode.Open, FileAccess.Read);
excelReader = ExcelReaderFactory.CreateOpenXmlReader(excelStream);
excelDataSet = excelReader.AsDataSet();
如果使用EPPlus,我的连接代码如下
If using EPPlus my connection code looks like
excelPackage = new ExcelPackage(new FileInfo(excelFilePath));
excelWorkbook = excelPackage.Workbook;
excelSheet = excelWorkbook.Worksheets[1];
EPPlus具有一些与保护相关的方法,但我不知道如何使用它们. ExcelDataReader似乎没有任何与保护有关的方法.
EPPlus has some protection related methods but i can't figure out how to use them. ExcelDataReader doesnt seem to have any protection related methods.
感谢任何提示,谢谢.
我已经知道密码
使用EPPlus,您可以使用
With EPPlus you can use
excelPackage = new ExcelPackage(new FileInfo(excelFilePath), "mypassword");
ExcelDataReader现在支持打开受密码保护的工作表.我在他们的GitHub上打开了 issue ,询问他们是否有这种支持,并收到回复说他们没有,但是一段时间后,他们增加了对某些密码方法的支持.他们仍然不支持的密码方法的详细信息在链接中.
ExcelDataReader now supports opening password protected sheets. I opened an issue on their GitHub asking if they have such support and received a response saying that they do not, but after sometime they added support for some password methods. Details on the password methods they still do not support are in the link.