How to use EPPlus read an Excel 2010 file that has workbook protection?

不打扰是莪最后的温柔 提交于 2019-12-11 14:15:54

问题


When I use the code below to read an Excel 2010 file that has password protection enabled for the workbook:

using (FileStream file = new FileStream(fileName,
       FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite))
{
     ExcelPackage ep = new ExcelPackage();

     try
     {
         ep = new ExcelPackage(file);
     }
     catch (Exception ex)
     {
         string strErr = ex.message;
     }
}

...I get an exception. Any example code to read a Excel 2010 file that has password protection, using EPPlus?


回答1:


Faced with the same problem. In Excel 2010 encryption algorythm is differs from 2007. Fortunately EPPlus 4.0 Beta 2 was released. Works fine with 2010+, but can not yet decrypt 2007 excel.



来源:https://stackoverflow.com/questions/20671972/how-to-use-epplus-read-an-excel-2010-file-that-has-workbook-protection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!