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

New Post: Excel 2013 - 2010 compatibility

$
0
0
I had the same problem happening apparently only on not very updated Office 2010 Standard installations.

The (very dirty) workaround I found (deducing it from this useful post) is removing those extensions completely, as I didn't need them.

After saving the workbook with ClosedXML I used the OOXML library directly doing this (in both workbook.xml and styles.xml):
using (SpreadsheetDocument excelDoc = SpreadsheetDocument.Open(ms, true))
{
    if (excelDoc.WorkbookPart.Workbook.Descendants<WorkbookExtensionList>().Any())
    {
        excelDoc.WorkbookPart.Workbook.RemoveAllChildren<WorkbookExtensionList>();
        excelDoc.WorkbookPart.Workbook.Save();
    }

    if (excelDoc.WorkbookPart.WorkbookStylesPart.Stylesheet.Descendants<StylesheetExtensionList>().Any())
    {
        excelDoc.WorkbookPart.WorkbookStylesPart.Stylesheet.RemoveAllChildren<StylesheetExtensionList>();
        excelDoc.WorkbookPart.WorkbookStylesPart.Stylesheet.Save();
    }
}
As a note, it appears that fully updated Office 2010 Professional installation do not corrupt the files after saving, in my experience only Office 2010 Standard did this.

I hope this can be useful.

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>