OpenXML corrupts excel file when I set a pageSetup
<p>I have a excel file created with DevExpress from my program. I need to add horizontal break page in this file but I can't because my DevExpress version does not handle it. So I use OpenXML in a separate class to retrieve the generated excel file in order to add it horizontal break page.</p>

<p>After the DevExpress generation, my file looks like this :
<a href="https://i.stack.imgur.com/tJyWB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tJyWB.png" alt="enter image description here"></a></p>

<p>So it has 6 pages. I'd like to have this instead of:
<a href="https://i.stack.imgur.com/rblxh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rblxh.png" alt="enter image description here"></a></p>

<p>In order to print each tab on a separate sheet.</p>

<p>So I used PageSetup from openXML to define the width and height of my excel file :</p>

<pre><code>private void InsertPageBreaks()
{
    //uint columnIndex = 17U;
    uint rowIndex = 42;

    SpreadsheetDocument sd = SpreadsheetDocument.Open("c:\\temp\\ExcelExport1.xlsx", true);
    try
    {

        WorkbookPart workbookPart = sd.WorkbookPart;
        WorksheetPart worksheetPart = workbookPart.WorksheetParts.Last();

        // Uncomment the following line to insert row page breaks.
        InsertHorizontalPageBreak(rowIndex, worksheetPart);

        PageSetup pageSetup = new PageSetup() {FitToHeight = 2, FitToWidth = 1};
        worksheetPart.Worksheet.AppendChild(pageSetup);

    }
    finally
    {
        if (sd != null)
            ((IDisposable)sd).Dispose();
    }
}
</code></pre>

<p>But after processing, when I try to open the file an error is showing up "Sorry we found a problem with some content [...]". </p>

<p>Do you guys have any idea how to help me ?</p>

<p>Many thanks !</p>