I have a workbook with no password that I read in to the Workbook object. I use that file to write out a different file with password protection. When I try to read the file that was written with the same password into a Workbook object, I get the following error:
"Index was out of range. Must be non-negative and less than the size of the collection."
I created a small application with the following code
try
{
LoadOptions loadOptions = new LoadOptions(LoadFormat.Excel97To2003);
Workbook readWorkbook = new Workbook("C:\\Documents and Settings\\Cindy Peterson\\Desktop\\Password Test.xls", loadOptions);
readWorkbook.Settings.Password = "test";
SaveOptions SaveOptions = new Aspose.Cells.XlsSaveOptions(SaveFormat.Excel97To2003);
readWorkbook.Save("C:\\Documents and Settings\\Cindy Peterson\\Desktop\\Password Test2.xls", SaveOptions);
FileStream stream = new FileStream("C:\\Documents and Settings\\Cindy Peterson\\Desktop\\Password Test2.xls", FileMode.Open);
loadOptions.Password = "test";
Aspose.Cells.Workbook workbook = new Workbook(stream, loadOptions);
}
catch (Exception ex)
{
string message = ex.Message;
}
The excel file that I used to create the issue is included but it's just a simple excel file with some text in it...nothing special. This does NOT happen when reading in an XLSX file and using the XLSX LoadFormat and SaveFormats.
This is currently a production issue for us so any help would be greatly appreciated.