currently I am using Cells 8.6.0.4 and when I try to open one password protected document without providing correct password I am getting:
Invalid password
but I if I try to open same document always sending same, wrong, password after second try I am getting that password.
Coding is extremely simple:
public void OpenDoc()
{
LoadOptions lOpt = new LoadOptions();
for (int i = 0; i < 10; i++)
{
lOpt.Password = "control1";
FileStream fs = new FileStream(@"PassOpen.xlsx", FileMode.Open);
try
{
Workbook doc = new Workbook(fs, lOpt);
Console.WriteLine("Pass OK");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
fs.Dispose();
fs = null;
}
}
Test document is attached (in debug folder, called PassOpen.xlsx and password to open it in "open" and not "control1".
Console output is:
d:\_Projects\Threads\WORD\PDF\bin\Debug>pdf Invalid password. Pass OK Pass OK Pass OK Pass OK Pass OK Pass OK Pass OK Pass OK Pass OK
Btw. I also attached test project. Simply run PDF.exe.
Can you please check?
P.S. For sample file PassOpen.xls (also in debug folder) everything works as it should.
My problem is that users are giving me lists of password that I should use to open documents so I am looping through the list. As I am getting "Pass ok" when I try to process document this will not work but strangely doc is not null.
Thank you for sharing the code and sample spreadsheets.
We have evaluated the presented scenario while using the latest version of Aspose.Cells for .NET 8.6.0.4, and we are able to observe the said issue. In case of XLSX, the API accepts the invalid password and loads the spreadsheet in an instance of Workbook on second try, whereas in case of XLS, the behavior is as expected. We have logged this incident in our bug tracking system as CELLSNET-43976 for further investigation and correction purposes. Our product team will further look into the details of this problem and we will keep you updated on the status of correction. We apologize for your inconvenience.
You are right, the problem occurs only when instance of LoadOptions is re-used. When you initialize in within the loop, it is not being reused therefore the results are correct. I have logged these observations to the aforementioned ticket for product team’s review.
This is to inform you that the product team has resolved the problem logged earlier as CELLSNET-43976. As soon as the next build of the Aspose.Cells for .NET API is available for your testing, we will inform you here in reference to the aforementioned ticket.
Good to know that it figures out your issue now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.