XLSX- how to get rid of the default namespace prefix x :?

I am creating an XLSX table using the OOXML SDK and I need to get rid of the x: namespace prefix. How can I achieve this?

 using (SpreadsheetDocument doc = SpreadsheetDocument.Open ("template.xlsx", true))
             {
                 // Save the shared string table part
                 if (doc.WorkbookPart.GetPartsOfType (). Count ()> 0)
                 {
                     SharedStringTablePart shareStringPart = 
doc.WorkbookPart.GetPartsOfType (). First (); shareStringPart.SharedStringTable.Save (); } // Save the workbook doc.WorkbookPart.Workbook.Save (); }

Here, the original XLSX file comes from Excel 2007 and does not have a prefix, however, after the save operation, the prefix appears. How can i avoid this?

+7
namespaces spreadsheetml openxml openxml-sdk
source share
2 answers

Here is a modified version of the stylesheet linked by divo that shares only one namespace and copies the rest of the verbatim version:

 <xsl:stylesheet version="1.0" xmlns:x="namespace-to-strip" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="no" encoding="UTF-8"/> <xsl:template match="/|comment()|processing-instruction()"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="x:*"> <xsl:element name="{local-name()}"> <xsl:apply-templates select="@*|node()"/> </xsl:element> </xsl:template> <xsl:template match="@x:*"> <xsl:attribute name="{local-name()}"> <xsl:value-of select="."/> </xsl:attribute> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> 
+3
source share

If I'm not mistaken, the source file is also named - only in the form of a default namespace. What is wrong with the namespace?

0
source share

All Articles