I create PowerPoint presentations via OpenXml. The slides of the presentations are enriched with embedded objects. Typically Excel documents are embedded. Beside having the image and the document prepared for embedding, Excel needs another information which area shall be shown to the user when the document is opened in PowerPoint.
This information can be added to the Excel workbook by adding OleSize class to the workbook part. Please ignore that this code doesn't check for existance of that fragment which would certainly lead to an issue. This is just a simple example.
var oleSize = new OleSize() {Reference = "A1:H12"};
var workbook = document.WorkbookPart.Workbook;
workbook.Append(oleSize);
When just added to the end of the list of OpenXmlElements of the workbook class, Excel will show an error message dialog saying that the file is corrupt, it is not repairable. Putting this element directly after PivotCache OpenXmlElement does work as a workaround. Now I experienced that Excel also raises that message when the OpenXmlElement is available before OleSize.
I cannot find any information about the necessity of an order of OpenXmlElements for that specific class.
Any hint is highly appreciated.
You're right about the order you list in your answer. In the OpenXML Specification document that you refer to there is an XSD (page 3936) for the
Workbook
which shows that the order is indeed mandatory as it's defined as aSequence
:If you're interested, I have an answer here which shows one way of adding items into the correct place in the file.