locked
exception while opening excel file using OpenXML. RRS feed

  • Question

  • User-616655518 posted

    Hi,

    i am having application developed in .Net 2.0 and using OpenXML to import excel file into aplication but getting following exception on this line of code

    SpreadsheetDocument myWorkbook = SpreadsheetDocument.Open(Path, true);

    Can anybody please help me on this as this is bvery much urgent for me.

    Following are exception details

    --------------------------------- Error message -------------------------

    System.IO.FileFormatException: File contains corrupted data.
       at MS.Internal.IO.Zip.ZipIOEndOfCentralDirectoryBlock.FindPosition(Stream archiveStream)
       at MS.Internal.IO.Zip.ZipIOEndOfCentralDirectoryBlock.SeekableLoad(ZipIOBlockManager blockManager)
       at MS.Internal.IO.Zip.ZipIOBlockManager.LoadEndOfCentralDirectoryBlock()
       at MS.Internal.IO.Zip.ZipArchive..ctor(Stream archiveStream, FileMode mode, FileAccess access, Boolean streaming, Boolean ownStream)
       at MS.Internal.IO.Zip.ZipArchive.OpenOnFile(String path, FileMode mode, FileAccess access, FileShare share, Boolean streaming)
       at System.IO.Packaging.ZipPackage..ctor(String path, FileMode mode, FileAccess access, FileShare share, Boolean streaming)
       at System.IO.Packaging.Package.Open(String path, FileMode packageMode, FileAccess packageAccess, FileShare packageShare, Boolean streaming)
       at System.IO.Packaging.Package.Open(String path, FileMode packageMode, FileAccess packageAccess, FileShare packageShare)
       at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.OpenCore(String path, Boolean readWriteMode)
       at DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(String path, Boolean isEditable, OpenSettings openSettings)
       at DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(String path, Boolean isEditable)
       at Banking_ImportStatements.ImportOnlineTemplate(String name, Int64 len) in e:\Projects\Siondo ERP\2 Siondo ERP EXECUTION\3 Source Code\SiondoERP\SiondoERPUI\Banking\ImportStatements.aspx.cs:line 1121} 

     

    Thanks & Regards,

    Vikas Jaigude.

    Tuesday, June 29, 2010 5:23 AM

All replies

  • User-481631678 posted

    I have not worked on OpenXML but i think that you should save your excel file in XML format. Exact name of format is XML Spreadsheet 2003. Use file->save as and select XML Spreadsheet 2003 as output format.



    Tuesday, June 29, 2010 6:59 AM