Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
Excel file corrupted after load/save
posted

Hi, 

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 : 

using System;
using Infragistics.Documents.Excel;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            const string filePath = "D:\\Template - ErrorAfter4Saves.xlsx";

            for (var i = 0; i < 4; i++)
            {
                var workbook = Workbook.Load(filePath);
                workbook.Save(filePath);
            }

            Console.WriteLine("File Corrupted !");
            Console.ReadLine();
        }
    }
}

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.

Parents
No Data
Reply
  • 34690
    Offline posted

    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.

Children