OpenXML won't read file created with ZLIB 1.2.8

Home Forums SpreadsheetML OpenXML won't read file created with ZLIB 1.2.8

This topic contains 2 replies, has 2 voices, and was last updated by  david_vsn 10 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3697

    david_vsn
    Participant

    I have a program that uses ZLIB 1.2.8 to zip the XML files into an Excel file.
    Excel reads the file fine, and WinZip handles it OK too, but OpenXML comes up with an error:

    Server Error in ‘/’ Application.
    The specified package is invalid. The main part is missing.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: DocumentFormat.OpenXml.Packaging.OpenXmlPackageException: The specified package is invalid. The main part is missing.

    Source Error:
    Line 38: using (ClosedXML.Excel.XLWorkbook workBook = new ClosedXML.Excel.XLWorkbook(path))

    The content is OK as when I unzip the contents and re-zip it with WinZip it reads fine into OpenXML. I conclude there must a problem in OpenXML in reading the zip created by ZLIB 1.2.8. The ZLIB library (http://zlib.net/) widely used, so I’m not sure what the incompatibility is.

    Any pointers to a solution or where to post this bug would be helpful.

    Thanks,
    David.

    #3717

    Eric White
    Keymaster

    Hi,

    This is an interesting bug, and given the opacity (to me) of the internals of zip files, I am uncertain of the source of the issue.

    Which version of the Open-Xml-Sdk are you using? If you are using 2.5, then you might try 2.6, and vice versa. 2.5 and 2.6 use different libraries for reading the zip file. 2.5 uses a weird internal library that is only (afaik) used by the Open XML SDK. 2.6 uses System.IO.Compression, which is a newer, more modern implementation for ZIP.

    Cheers, Eric

    #3725

    david_vsn
    Participant

    Thanks Eric,

    I’ve followed your suggestion and have tried both versions 2.5 and 2.6 and they both give the same error. Sadly, we have switched to the NPOI library which works with the file created with ZLIB, although more slowly. The strange thing is that Excel handles the file fine, and I would have through it would have used something like System.IO.Compression. Thanks for your help, that was useful.

    Thanks again,
    David.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.