none
OpenXmlPackage.Close() changing namespace in styles.xml to have a prefix RRS feed

  • Question

  • Hi all;

    We have a case where calling OpenXmlPackage.Close() will write the styles.xml (and other files) of an XLSX file as:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <x:styleSheet xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
    	<x:fonts count="6" x14ac:knownFonts="1">
    

    This is legal but our code assumes that the namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main will have no prefix. We're fixing this in our code but in the meantime, is there a way to not have this happen? Because I'm guessing other programs out there may also make the same assumption.

    thanks - dave

     


    The future of B.I. - Raw & Uncut
    Wednesday, August 10, 2011 10:57 PM

Answers

  • Hello DavidThi808,

    May I inquire why you assume the http://schemas.openxmlformats.org/spreadsheetml/2006/main namespace will not have a namespace prefix?

    How do you specify a namespace for an element without either a prefix or the tag <xmlns:http://schemas.openxmlformats.org/……./My tag”> verbiage?

    The .NET packaging classes generate the namespace prefix for you.  You can package the workbook xml without using the .NET packaging namespace – as was done before .NET 3.5 but, unless you were working with legacy xml code, why would anyone do that now?

    If you want to have the .NET classes or the .NET namespace code modified you need to open a support incident with Microsoft Paid support.

    Please visit the below link to see the various paid support options that are available to better meet your needs.
    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Regards,
    Chris Jensen
    Senior Technical Support Lead

    • Proposed as answer by cjatmsModerator Friday, August 12, 2011 2:14 PM
    • Marked as answer by DavidThi808 Friday, August 12, 2011 3:28 PM
    Friday, August 12, 2011 2:13 PM
    Moderator

All replies

  • Hi Dave,

    We are doing the research about the problem. There might be some delay about the response. Appreciate your patience.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, August 12, 2011 1:50 AM
  • Hello DavidThi808,

    May I inquire why you assume the http://schemas.openxmlformats.org/spreadsheetml/2006/main namespace will not have a namespace prefix?

    How do you specify a namespace for an element without either a prefix or the tag <xmlns:http://schemas.openxmlformats.org/……./My tag”> verbiage?

    The .NET packaging classes generate the namespace prefix for you.  You can package the workbook xml without using the .NET packaging namespace – as was done before .NET 3.5 but, unless you were working with legacy xml code, why would anyone do that now?

    If you want to have the .NET classes or the .NET namespace code modified you need to open a support incident with Microsoft Paid support.

    Please visit the below link to see the various paid support options that are available to better meet your needs.
    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Regards,
    Chris Jensen
    Senior Technical Support Lead

    • Proposed as answer by cjatmsModerator Friday, August 12, 2011 2:14 PM
    • Marked as answer by DavidThi808 Friday, August 12, 2011 3:28 PM
    Friday, August 12, 2011 2:13 PM
    Moderator
  • Hi;

    It's a bug in our code that we assume it will not have a prefix (as Excel always writes it that way). We're fixing the bug but I was hoping you had a way to force that behavior.

    You are correct that using a prefix is valid.

    thanks - dave


    The future of B.I. - Raw & Uncut
    Friday, August 12, 2011 3:29 PM