When I try to open a password protected file, after typing the password into the pop-up Excel then displays the error message:
"Excel cannot open the file 'myfile.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."
Recreate it with code like this:
```
ExcelPackage package = new ExcelPackage();
var sheet = package.Workbook.Worksheets.Add("Sheet 1");
package.Encryption.Password = "mypassword";
using (var fs = new FileStream("C:\\my\\path\\myFile.xlsx", FileMode.Create))
{
package.SaveAs(fs);
}
```
package.Encryption.Version is set to EncryptionVersion.Agile, but I did try changing it to EncryptionVersion.Standard with
```
package.Encryption.Version = EncryptionVersion.Standard;
```
and that didn't help either. Nor did using the alternative SaveAs signature of
```
package.SaveAs(fs, "myPassword");
```
I'm using Excel 2013 on Windows 10 Pro 64-bit. This was working fine: maybe there has been a recent Windows or Excel update that broke it?
Comments: In case I wasn't clear, opening the file without the password is fine e.g. a file generated with ``` ExcelPackage package = new ExcelPackage(); var sheet = package.Workbook.Worksheets.Add("Sheet 1"); using (var fs = new FileStream("C:\\my\\path\\myFile.xlsx", FileMode.Create)) { package.SaveAs(fs); } ``` opens ok.
"Excel cannot open the file 'myfile.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."
Recreate it with code like this:
```
ExcelPackage package = new ExcelPackage();
var sheet = package.Workbook.Worksheets.Add("Sheet 1");
package.Encryption.Password = "mypassword";
using (var fs = new FileStream("C:\\my\\path\\myFile.xlsx", FileMode.Create))
{
package.SaveAs(fs);
}
```
package.Encryption.Version is set to EncryptionVersion.Agile, but I did try changing it to EncryptionVersion.Standard with
```
package.Encryption.Version = EncryptionVersion.Standard;
```
and that didn't help either. Nor did using the alternative SaveAs signature of
```
package.SaveAs(fs, "myPassword");
```
I'm using Excel 2013 on Windows 10 Pro 64-bit. This was working fine: maybe there has been a recent Windows or Excel update that broke it?
Comments: In case I wasn't clear, opening the file without the password is fine e.g. a file generated with ``` ExcelPackage package = new ExcelPackage(); var sheet = package.Workbook.Worksheets.Add("Sheet 1"); using (var fs = new FileStream("C:\\my\\path\\myFile.xlsx", FileMode.Create)) { package.SaveAs(fs); } ``` opens ok.