0
當我試圖打開加密文檔我有這樣的例外如何使用EPPlus檢查是否有密碼保護的excel文件?
System.Exception : Can not open the package. Package is an OLE compound document. If this is an encrypted package, please supply the password
我寫這篇硬方法測試
public bool HasPassword()
{
try
{
if(File.Exists(FileName))
{
var fileStream = File.Open(FileName, FileMode.Append);
var package = new ExcelPackage();
package.Load(fileStream);
}
}
catch(Exception)
{
return true;
}
return false;
}
,但我認爲這是錯誤的做法。
如何檢查是否有密碼保護的Excel文件?