Encryted Files

Hello there,

I am using Aspose Cells .NET and trying to open an encrypted file which I have created (with a password set on it of “password”). However when I run the below code I am always falling into the catch block. Can anyone point me in the right direction please?


//Create a License object
License license = new License();

//Set the license of Aspose.Cells to avoid the evaluation limitations
license.SetLicense(“Aspose.Cells.lic”);

string password = “password”;
LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
loadOptions.Password = password ;

try
{
Workbook workbook = new Workbook(“C:\ACE Log\test.xlsx”, loadOptions);
Console.WriteLine(string.Format(“Success - the password is {0}”),password );
}
catch (Exception)
{
Console.WriteLine(“Password not accepted”);
}
Console.ReadLine();

Hi,


Could you attach your password protected Excel file (encrypted file) here. We will check your issue soon.

Also, which version of the product you are using?

Thank you.

Please find attached the spreadsheet that I am using and the version of Aspose Cells I am using is v2.0.50727

Kindest.

David

Hi,


Thanks for the template file.

After an initial test, I can fine the issue as you have mentioned by opening your encrypted file using the following code. i got the exception:

“Index (zero based) must be greater than or equal to zero and less than the size of the argument list.”

Sample code:

string password = “password”;
LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
loadOptions.Password = password;

try
{
Workbook workbook = new Workbook(“e:\test2\test.xlsx”, loadOptions);
Console.WriteLine(string.Format(“Success - the password is {0}”), password);
}
catch (Exception ee)
{
Console.WriteLine(ee.Message + " – Password not accepted");
}

I have logged a ticket with an id “CELLSNET-41402” for your issue. We will look into your issue soon.

Thank you.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

After further investigation, we found that it’s the bug of your code.

Please modify the code about the usage of
the string.Format as the following:

Console.WriteLine(string.Format("Success

  • the password is {0}", password));