Can you use closedxml with an xlsx file created with openxmlsdk?

Sep 29, 2012 at 8:32 PM

Hello.  Is it possible to use closedxml on an xlsx file created with openxmlsdk?  If I open the file with excel and resave it, it appears to work. Unfortunately, our server does not have excel installed.  I would be very grateful for any assistance.

-Thank you

Coordinator
Sep 29, 2012 at 10:34 PM

Sure. ClosedXML uses the OpenXML SDK underneath....

Sep 30, 2012 at 12:38 AM
Edited Sep 30, 2012 at 12:39 AM

 

Thank you for such a quick response.  I was pretty sure I should be able to.  Can anyone offer any assistance as to what I might be missing:

It is appears to be finding the  file because if I open the file with excel and do a save as and then run the code, it does not produce an error.

using ClosedXML.Excel; - added the ClosedXML.dll to my references (already had DocumentFormat.Openxml)

 I create the spreadsheet using:

 using (SpreadsheetDocument myDoc = SpreadsheetDocument.Open(sTodaysFile, true))

etc..

 Then after myDoc.close() 

 var wb = new XLWorkbook(sTodaysFile);

 

Object reference not set to an instance of an object. Stack Trace:    at ClosedXML.Excel.XLWorkbook.LoadRows(Stylesheet s, NumberingFormats numberingFormats, Fills fills, Borders borders, Fonts fonts, XLWorksheet ws, SharedStringItem[] sharedStrings, Dictionary`2 sharedFormulasR1C1, Dictionary`2 styleList, Row row)

   at ClosedXML.Excel.XLWorkbook.LoadSpreadsheetDocument(SpreadsheetDocument dSpreadsheet)

   at ClosedXML.Excel.XLWorkbook.LoadSheets(String fileName)

   at ClosedXML.Excel.XLWorkbook.Load(String file)

   at ClosedXML.Excel.XLWorkbook..ctor(String file, XLEventTracking eventTracking)

   at ClosedXML.Excel.XLWorkbook..ctor(String file)

 

Thank you again.

Coordinator
Sep 30, 2012 at 2:29 AM

Create an issue and attach the file you're trying to open.

Sep 30, 2012 at 10:17 AM

I am unable to attach the file due to the sensitive nature of the company data.  When I open the file created with openxml sdk with excel and then save as...it does work.  I did not open an issue since I cannot give you the file and since I know you can make the file readable by opening and resaving, not sure where to go from here.  I will keep trying and thank you for all your help.