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.
Hello Infragistics User,
I have been investigating into this behavior you are reporting, and I have put together a sample project using the code that you have provided as well as the Excel file that you have provided, and after saving and loading four times, I am seeing an error on load of the Excel file, but it isn't really a full "corruption" on my end.
When trying to load the Excel file, I am receiving a message that reads:
"We found a problem with some content in <filename>. Do you want us to recover as much as we can?"
If I click "Yes" on this dialog, it appears that everything is restored normally, and so it does appear that there is an issue when saving the Workbook multiple times, although I cannot be sure if this completely matches the behavior you are seeing. Are you seeing the same behavior in this case, or are you seeing a more "complete corruption" of the Excel file, in that you are completely unable to reopen it after saving?
It also may be helpful if you can please provide the Infragistics for Windows Forms version that you are using. My tests were made against specific version 17.2.20172.2006 in Infragistics for Windows Forms 2017 Volume 2. Is this the same version you are using? If not, would it be possible for you to please provide the version you are using?
Please let me know if you have any other questions or concerns on this matter.
I finally found from where my problem is.
I fixed my excel file which had wrong formulas.
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