I want to export data back to an XML file, after some modification to data I imported from some other XML file (those first line variables never change).
When I click Developer >> export
Excel shows:
cannot save or export XML data. The XML maps in this workbook are not exportable.
This happes even when I do nothing to modify the data.
I watched several export tutorials on YouTube, but none cover my problem.
The usual reason is the Excel doesn't understand very complicated XML.
From office.microsoft.com:
An XML mapping cannot be exported if the mapped element’s relationship with other elements cannot be preserved. This relationship may not be preserved for the following reasons:
The schema definition of a mapped element is contained within a sequence with the following attributes:
- The maxoccurs attribute is not equal to 1.
- The sequence has more than one direct child element defined, or has another compositor as a direct child.
- Nonrepeating sibling elements with the same repeating parent element are mapped to different XML tables.
- Multiple repeating elements are mapped to the same XML table, and the repetition is not defined by an ancestor element.
- Child elements from different parents are mapped to the same XML table.
Additionally, the XML mapping cannot be exported if it contains one of the following XML schema constructs:
List of lists
- One list of items contains a second list of items.
Denormalized data
- An XML table contains an element that has been defined in the schema to occur once (the maxoccurs attribute is set to 1). When you add such an element to an XML table, Excel fills the table column with multiple instances of the element.
Choice
- A mapped element is part of a schema construct.
I had a similar issue. It was a simple sheet and contained just 8 columns but the XML export kept throwing this error. I found that if the order in which the elements appeared in the XML schema did not match the order in which the columns appeared in the sheet, I got this error. I rearranged the columns in my sheet to be the same as the order of elements in the schema & the export became successful.
In my case i wanted to export a simple table as an xml file without a prior existing xsd or xml file. So i did this
I wrote the following xsd in an editor and saved it to a file
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Root">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="Sample_XML_Export">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Foo" type="xsd:int"/>
<xsd:element name="Bar" type="xsd:string"/>
<xsd:element name="Baz" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
This xsd file must be imported into excel. You need to activate the developer tab in Excel. On this tab you can import from XML source (see button "XML...").
After you imported the xsd file you will see a tree structure (see folder
Root
and Sample_XML_Export
).
Now you need to relate a node below Sample_XML_Export
to an excel-column. Select a node and right click it to map this node to a column
Now select the column you want to map / to relate to the node by clicking on the column header.
Under File / Save as or Export you can save the xls file as an xml file. This is the exported xml data
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root>
<Sample_XML_Export>
<Foo>1234</Foo>
<Bar>122</Bar>
<Baz>12</Baz>
</Sample_XML_Export>
<Sample_XML_Export>
<Foo>4567</Foo>
<Bar>144</Bar>
<Baz>13</Baz>
</Sample_XML_Export>
<Sample_XML_Export>
<Foo>7890</Foo>
<Bar>187</Bar>
<Baz>14</Baz>
</Sample_XML_Export>
</Root>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With