Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Commented Unassigned: Excel workbook corrupt after saving [9429]

$
0
0
I have an xlsx workbook that is used as a template. Through a ridiculous amount of coding, I have built a library using OpenXML that _almost_ preserves all formatting of the original file after updating the cells with data. Saddened by the reams of code to accomplish this, I turned to ClosedXML and got quite far with a fraction of the code, and was very happy...until I encountered the attached spreadsheet and executed the following code.

```
var workbook = new XLWorkbook(filePath);
workbook.Save();
```

When I opened the file in Excel, I encountered the prompt to recover the contents of the workbook, since Excel found unreadable content. I clicked Yes. Excel flickered a little, and then I am presented with the alert:

> "The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt."

The only hint I have found so far is that the conditional formatting elements in Sheet1.xml are different after saving through ClosedXML than before.

Comments: We are seeing the same issue here too.

Viewing all articles
Browse latest Browse all 1877

Trending Articles