c# - OpenXML/SpreadsheetLight: File contains corrupted data for xlsx - Only happens on server -


i'm having strange problem. trying use openxml/spreadsheetlight library process data of user uploaded excel file (only .xlsx not .xls), getting error when trying run code on live server.

i tested code on local machine , on staging server instance, in both cases uploaded .xlsx file , code able process correctly. when testing on our live server, , using exact same .xlsx file, code spits out error: file contains corrupted data.

what have tried far:

  1. i checked file uploaded temp directory on server.
  2. i checked iis user has permissions access file in temp directory.
  3. i checked uploaded file not corrupted , opened excel.
  4. clean build , re-deploy code (ensuring exact same code on staging server made live server).
  5. redeployed documentformat.openxml.dll , spreadsheetlight.dll server.

at point i'm not sure else check or issue be, suggestions on possibly welcome.

here error message/stack trace:

file contains corrupted data. : @ ms.internal.io.zip.zipioextrafieldzip64element.parsedatafield(binaryreader reader, uint16 size)    @ ms.internal.io.zip.zipioextrafieldelement.parse(binaryreader reader, zipiozip64extrafieldusage zip64extrafieldusage)    @ ms.internal.io.zip.zipioextrafield.parserecord(binaryreader reader, zipiozip64extrafieldusage zip64extrafieldusage, uint16 expectedextrafieldsize)    @ ms.internal.io.zip.zipiolocalfileheader.parserecord(binaryreader reader, encoding encoding)    @ ms.internal.io.zip.zipiolocalfileblock.parserecord(binaryreader reader, string filename, int64 position, zipiocentraldirectoryblock centraldir, zipiocentraldirectoryfileheader centraldirfileheader)    @ ms.internal.io.zip.zipioblockmanager.loadlocalfileblock(string zipfilename)    @ ms.internal.io.zip.ziparchive.getfile(string zipfilename)    @ ms.internal.io.zip.ziparchive.getfiles()    @ system.io.packaging.zippackage.contenttypehelper..ctor(ziparchive ziparchive, ignoreditemhelper ignoreditemhelper)    @ system.io.packaging.zippackage..ctor(stream s, filemode mode, fileaccess access, boolean streaming)    @ system.io.packaging.package.open(stream stream, filemode packagemode, fileaccess packageaccess, boolean streaming)    @ documentformat.openxml.packaging.openxmlpackage.opencore(stream stream, boolean readwritemode)    @ documentformat.openxml.packaging.spreadsheetdocument.open(stream stream, boolean iseditable, opensettings opensettings)    @ spreadsheetlight.sldocument.openexistingspreadsheet(string sheetnameonopen)    @ myprojectname.fileuploader.loadfilefromexcelfile() in c:\users\username\myprojectname\fileuploader.aspx.cs:line 123 

here actual code:

// make sure file uploaded if (myfileupload.hasfile && !string.isnullorempty(myfileupload.filename)) {     // make sure file .xlsx     string fileext = path.getextension(myfileupload.filename);     if (fileext.tolower() == ".xlsx")     {         // upload file temp directory         string filepath = string.empty;         string filename = path.getfilename(myfileupload.filename);         string targetfolder = system.io.path.gettempfilename();           filepath = targetfolder + filename;          // replace existing file @ location         if (system.io.file.exists(filepath))         {             system.io.file.delete(filepath);         }          myfileupload.saveas(filepath);          // open file use         using (sldocument thespreadsheet = new sldocument(filepath, "sheet1")) // <-- error occurs here         {             // stuff file here...         }     } } 

the line throwing error line:

using (sldocument thespreadsheet = new sldocument(filepath, "sheet1"))


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -