OpenXml: Worksheet Child Elements change in ordering results in a corrupt file

According to the Standard ECMA-376 Office Open XML File Formats, CT_Worksheet has a required sequence:

CT_Worksheet Schema Diagram

The reason the following is crashing:

workSheet.Append(sheetViews);
workSheet.Append(columns);
workSheet.Append(sheetData);
workSheet.Append(drawing);
workSheet.Append(mergeCells);

Is because you have drawing before mergeCells. As long as you append your mergeCells after drawing, your code should work fine.

Note: You can find the full XSD in ECMA-376 3rd edition Part 1 (.zip) -> OfficeOpenXML-XMLSchema-Strict -> sml.xsd.