Sign UpSign Up   Sign InSign In Welcome Guest,
Live Chat Live Chat

2007 Excel file corrupted after save

Last post 07-06-2009, 5:50 PM by changcliu. 10 replies.
Sort Posts: Previous Next
  •  07-01-2009, 3:02 PM 186476

    2007 Excel file corrupted after save .NET

    Attachment: Present (inaccessible)

    I have a very simple 2007 excel file, after I open it and save with cells.dll, then try to open with MS office 2007, the file seems corrupted and asked me to repair. There is the repair message generated by MS 2007:

    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

    - <recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
      <logFileName>error301240_01.xml</logFileName>
      <summary>Errors were detected in file 'F:\filestore.xlsx'</summary>
    - <additionalInfo>
      <info>Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.</info>
      </additionalInfo>
      </recoveryLog>

    My cells.dll version is 4.7.1.8, runtime version = v1.0.3705

    There is my test code in c#: 

               string docFile = "BookGood.xlsx";
     
                System.IO.FileStream fstream = null;
                Workbook workbook = new Workbook();

                FileFormatType fileFormat = FileFormatType.Excel2007Xlsx;

                fstream = new System.IO.FileStream(docFile, FileMode.Open);

                workbook.Open(fstream, fileFormat);
                workbook.Save(fstream, fileFormat);


                fstream.Dispose();

                workbook = null;

    You can use your excel 2007 file or my uploaded one to verify.

     

    Chang

     

     
  •  07-01-2009, 4:58 PM 186486 in reply to 186476

    Re: 2007 Excel file corrupted after save

    Please please, we are in production support.... CL
     
  •  07-02-2009, 12:34 AM 186517 in reply to 186486

    Re: 2007 Excel file corrupted after save

    Hi,

     

    Thank you for considering Aspose.

    Please update your code as mentioned below and check if it works fine.

    string docFile = "BookGood.xlsx";

    System.IO.FileStream fstream = null;

    Workbook workbook = new Workbook();

     

    FileFormatType fileFormat = FileFormatType.Excel2007Xlsx;

    fstream = new System.IO.FileStream(docFile, FileMode.Open);

    workbook.Open(fstream, fileFormat);

    fstream.Dispose();

     

    fstream = new System.IO.FileStream(docFile, FileMode.Open);

    workbook.Save(fstream, fileFormat);

    fstream.Dispose();

     

    Thank You & Best Regards,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  07-02-2009, 8:30 AM 186596 in reply to 186517

    Re: 2007 Excel file corrupted after save .NET

    Attachment: Present (inaccessible)
    It doesn't help. This time, MS Office 2007 cannot even repair it. There is an error message when try to open worksheet.xml via winzip:

    Extracting to "C:\Documents and Settings\CLIU095\Local Settings\Temp\wz6f5b\"
    Use Path: yes   Overlay Files: yes
    Error in file #1:  bad Zip file offset (Error local header signature not found):  disk #1  offset: 2218

    I attached the output file renamed ext to zip for you to look.

    I try to open and save using workbook directly, which I think your library handles 2007 excel file correctly. However, I can not use this approach -- file will be locked if there is an IO error during open or save. With stream , I am able to close stream more safely.



    Chang
     
  •  07-02-2009, 10:29 AM 186611 in reply to 186596

    Re: 2007 Excel file corrupted after save

    Hi,

    Thank you for sharing the output file.

    We will look into it and get back to you soon.

    Thank You & Best Regards,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  07-03-2009, 12:45 AM 186688 in reply to 186596

    Re: 2007 Excel file corrupted after save

    Attachment: Present (inaccessible)

    Hi,

     

    Thank you for considering Aspose.

     

    Well, Aspose.Cells for .NET can handle 2007 excel file correctly and this feature is being used by many customers. It’s strange that you cannot get correct file with the previous code.

     

    Please try the attached simple console project in a clear machine and let us know about the results. This will help us figure out the issue soon.

     

    Thank You & Best Regards,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  07-03-2009, 10:29 AM 186811 in reply to 186688

    Re: 2007 Excel file corrupted after save

    I think is license code causes problem?

    I can run your or my own code without any problem, however, adding license will  corrupt file

                string AsposeLicenseFile = "Aspose.Total.lic";
                string licFile = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, AsposeLicenseFile); //System.Reflection.Assembly.GetExecutingAssembly().Location, AsposeLicenseFile);

                Aspose.Cells.License cellLicense = new Aspose.Cells.License();
                cellLicense.SetLicense(licFile);

    Is my license expired ? How can it only corrupt 2007 excel file?


     
  •  07-03-2009, 10:42 AM 186813 in reply to 186811

    Re: 2007 Excel file corrupted after save

    Hi,

    Thank you for considering Aspose.

    Please send us your license file and we will check it soon. Please follow the steps mentioned in the following link to send us the license file.

    http://www.aspose.com/corporate/purchase/faqs/send-license-to-aspose-staff.aspx

    Thank You & Best Regards,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  07-05-2009, 4:40 AM 186926 in reply to 186811

    Re: 2007 Excel file corrupted after save

    Hi,

    Thank you for considering Aspose.

    We have received your license file via email. We checked it and it works fine with the provided sample application. Please provide us further information regarding your system environment (e.g. OS, VS.NET version , 32 bit or 64 bit Machine etc). This will help us figure out the issue soon.

    Thank You & Best Regards,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  07-06-2009, 12:58 AM 186960 in reply to 186811

    Re: 2007 Excel file corrupted after save

    Hi,

    Thank you for considering Aspose.

    Also, Please make sure that the stream passed to workbook.Save() is a newly created stream. Passing a stream with data to workbook.Save() may corrupt file.

    System.IO.FileStream fstream = new System.IO.FileStream(docFile, FileMode.Create); // use FileMode.Create here, please do not use FileMode.Open

     

    workbook.Save(fstream, fileFormat);

     

    fstream.Dispose();

     

    Please feel free to contact us if you still find any problem.

     

    Thank You & Best Regards,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  07-06-2009, 5:50 PM 187164 in reply to 186960

    Re: 2007 Excel file corrupted after save

    hi,

    You are right . It works after I create a new filestream and save workbook object with this new stream.  Thanks for the help!

    CL

     
View as RSS news feed in XML