In my application, I have to load and save many times excel files.
Some of them become corrupted after multiple saves.
I tried with a sample project to load and save multiple times and for an excel document, it become corrupted after 4 load/save.
Here is my sample code :
static void Main(string args)
const string filePath = "D:\\Template - ErrorAfter4Saves.xlsx";
for (var i = 0; i < 4; i++)
var workbook = Workbook.Load(filePath);
Console.WriteLine("File Corrupted !");
And here is the excel file :
3225.Template - ErrorAfter4Saves.xlsx
If i try to open it after running my sample code, it will be corrupted.
I don't know why after 4 times.
Thank You for your answers.
I am glad to know that you were able to find out the root cause of the problem and fixed the file which had wrong formulas.
Although, I have experienced this issue myself and was not able to find out the specific file where the formulas were wrong due to multiple files and large database
Here are the work around we can try in such cases:
1) If your Excel spreadsheet contains valuable data you can Make the Excel File ‘Read-only’:
2) You can also Install Visual Basic Component
3) You can get help using the third party software solely created for Data recovery of corrupted/ partially corrupted Excel files. Here is a tool which I have personally used to repair my corrupted excel file : https://www.stellarinfo.com/repair-excel-file.php