Hi Aspose team,
I’m having an issue with the XLS file. After loading and saving it the first time, I tried to load the output file and save it again (second time), but it throws an error: “Index was outside the bounds of the array”.
I think something goes wrong with the file after the first save, but Microsoft Excel still opens both files just fine.
I’m using Aspose.Cell version 25.10.
Sample : sample.zip (892.4 KB)
Here is my code:
var workbook = new Workbook(@"D:\original.xls");
workbook.Save(@"D:\output.xls", SaveFormat.Excel97To2003);
Could you please help me check this issue and advise how to fix it?
Thank you.
@dunghnguyen
It seems you’re encountering an issue with saving an XLS file using Aspose.Cells. The error “Index was outside the bounds of the array” typically indicates a problem with the data structure or the way the file is being processed after the first save.
Here are a few steps you can take to troubleshoot and potentially resolve the issue:
-
Check for Corruption: Ensure that the original XLS file is not corrupted. Open it in Excel and save it again to see if that resolves any underlying issues.
-
Update Aspose.Cells: You’re using version 25.10, which may have bugs that have been fixed in later versions. Consider updating to the latest version of Aspose.Cells.
-
Use Different Save Formats: If you’re saving as SaveFormat.Excel97To2003, try saving it in a different format, such as SaveFormat.Xlsx, to see if the issue persists.
-
Inspect the Workbook: Before saving the workbook, check for any unusual data or structures (like empty rows or columns) that might be causing the issue. You can iterate through the sheets and cells to validate their contents.
-
Error Handling: Implement error handling around your save operation to catch and log any exceptions that may provide more insight into the issue.
Here’s a modified version of your code with error handling:
try
{
var workbook = new Workbook(@"D:\original.xls");
workbook.Save(@"D:\output.xls", SaveFormat.Excel97To2003);
}
catch (Exception ex)
{
Console.WriteLine("An error occurred: " + ex.Message);
}
If the problem continues, consider reaching out to the Aspose support forum with detailed information about the issue, including the specific error message and any relevant code snippets.
@dunghnguyen
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-59195
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Hi Aspose team,
I found a new sample related to this case. Sample files : test.zip (194.3 KB)
After the first save, output1 can be opened in Excel, but from Output2 onwards, the output size increases by 12KB, and Excel can’t open them anymore.
My code :
string tempDir = @"E:\test";
string inputFile = Path.Combine(tempDir, "Book1.xls");
for(int i = 1; i <= 7; i++)
{
string currentInput = i == 1 ? inputFile : Path.Combine(tempDir, $"output{i - 1}.xls");
string currentOutput = Path.Combine(tempDir, $"output{i}.xls");
using(var wb = new Workbook(currentInput))
{
wb.Save(currentOutput, SaveFormat.Excel97To2003);
}
}
Please check this case and get back to me.
@dunghnguyen
Thank you for your feedback. We can reproduce the issue by testing on the latest version v25.10 using the newly provided sample files and code. Output file crashes after opening the result file and saving it again.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-59208
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@dunghnguyen,
We are pleased to inform you that your issue (Ticket ID: “CELLSNET-59208”) has been resolved. The fix will be included in the upcoming release (Aspose.Cells v25.11) that we plan to release in the first half of November 2025. You will be notified when the next version is released.
@dunghnguyen,
This is to notify you that your issue (Ticket ID: “CELLSNET-59195”) has been resolved now. The fix will be included in the upcoming release (Aspose.Cells v25.11) that we plan to release in the first half of November 2025. You will be notified when the next version is released.