question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generated XLSX is invalid

See original GitHub issue

I use ClosedXML version 0.85.0.0. I have Excel 2016 document which seems to be valid. It can be opened and saved smoothly in Excel 2016. It contains no data. I use ClosedXML to open and save it but generated file is invalid. Excel reports that it has invalid structure and needs to be fixed. Here is the code to open and save: XLWorkbook workbook = new ClosedXML.Excel.XLWorkbook("aa.xlsx"); workbook.SaveAs("bb.xlsx"); The file bb.xlsx produced in ClosedXML version 0.80.0.0 was correct, while after upgrading to 0.85.0.0 it is incorrect. Please find attached source Excel document: aa.xlsx file aa.xlsx.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
jsmunroecommented, Jan 25, 2019

This is for people who find this in a search who are calling SaveAs to a MemoryStream and then using GetBuffer to get an array of bytes. Use ToArray on the stream instead of GetBuffer.

0reactions
Alt-WNcommented, Jan 9, 2017

I have tested 0.86. It works correct! Thanks.

Regards, Alt-WN

Read more comments on GitHub >

github_iconTop Results From Across the Web

Diagnosing Invalid XLSX - Microsoft Q&A
Hi, Our software generated an xlsx. Trying to open it in excel results in an error and Excel offers to repair the file,...
Read more >
[Fixed] Excel Cannot Open the File Because the Extension ...
Summary: This post discusses workarounds to resolve the 'Excel cannot open the file because the extension is not valid' error.
Read more >
Excel Cannot Open the File Because the Extension Is Not ...
Many times, this error occurs due to the incompatible file extension of the Excel file. MS Excel saves Excel workbooks as XLSX or...
Read more >
XLSX file via OpenXml SDK Both Valid and Invalid
I have a program which exports a System.Data.DataTable to an XLSX / OpenXml Spreadsheet. Finally have it mostly working. However when opening ...
Read more >
Excel produces invalid xls file when converting xlsx ...
Hello,. I am using Aspose.Cells to create Excel files (in xlsx format) from XML Spreadsheet format but users have discovered that when opening...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found