Problem when opening a protected XLSX file

Hello,

I’m just posting because I faced a strange problem. I am trying to open a file which is protected by password (workbook protection using Excel 2007). For some reason, the method Open does seems to fail, but in fact, nothing is loaded into my variable. Here is the exemple I tested:

I opened Excel, save a file in format 2003 (xls) called file_unprotected.xls.
Then I saved the same file in format 2007 called file_unprotected.xlsx
Then I protect the file and save it as file_protected.xls and file_protected.xlsx.
Finally I run the following code:

Workbook w1 = new Workbook();
w1.Open(“c:\file_unprotected.xls”);
Console.Write(w1.Worksheets.Count);

Workbook w2 = new Workbook();
w2.Open(“c:\file_protected.xls”);
Console.Write(w2.Worksheets.Count);

Workbook w3 = new Workbook();
w3.Open(“c:\file_unprotected.xlsx”);
Console.Write(w3.Worksheets.Count);

Workbook w4 = new Workbook();
w4.Open(“c:\file_protected.xlsx”);
Console.Write(w4.Worksheets.Count);

Workbook w5 = new Workbook();
w5.Open(“c:\file_protected.xlsx”, FileFormatType.Excel2007Xlsx);
Console.Write(w5.Worksheets.Count);

The output of my program is
3 3 3 0 3.

So to solve that problem, I have to specify the file format (Excel2007Xlsx). Is this normal that there is not even an exception raised in the scenario 4?

Rgds,
Alexandre

Hi,


Please try our latest version v7.0.1 in which we made several enhancements, it should work fine:
http://www.aspose.com/community/files/51/.net-components/aspose.cells-for-.net/entry328122.aspx

Please see the documents on opening and saving files according to new API model/approach.
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/opening-files.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/saving-files.html

Note: If you still find the issue, kindly give us your template file(s) here to show the issue, we will check it soon.

Thank you.