Excel structured-data mapping
Convert CSV to XML in Excel With a Defined XML Map
Map CSV fields to a simple XML schema in Excel for Windows, preserve identifiers, distinguish XML Data from Spreadsheet XML and validate the exported records.
To convert CSV to application-specific XML in Excel, import the CSV as a table, create an XML Map from the required schema, map its elements to cells and export XML Data. The legacy XML mapping feature is available in Excel for Windows desktop. Saving a workbook as XML Spreadsheet 2003 produces a workbook format, not an arbitrary XML structure requested by another application.
Obtain the destination schema first
Ask the receiving system for its XML schema, accepted example and field requirements. XML permits many different element names and hierarchies, so a file can be well-formed XML and still be entirely wrong for that application. The root element, record element and field types need an agreed meaning.
Microsoft’s mapping documentation identifies Windows desktop as the platform for XML Maps and explains the relationship between schema elements and worksheet cells. Mac and web Excel do not provide this same mapping workflow.
Import a small CSV with explicit types
ID,Name,Amount
00123,René,12.50
00999,North & East,0.00
Import the file through the text/CSV data path and keep ID as text. Its leading zeros are part of the identifier. Name is text, while Amount is a decimal quantity in this example. Save an Excel workbook copy so that the table and mapping can be retained separately from the CSV source.
Define a simple repeating record
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="records">
<xs:complexType><xs:sequence>
<xs:element name="record" minOccurs="0" maxOccurs="unbounded">
<xs:complexType><xs:sequence>
<xs:element name="id" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="amount" type="xs:decimal"/>
</xs:sequence></xs:complexType>
</xs:element>
</xs:sequence></xs:complexType>
</xs:element>
</xs:schema>This demonstration schema defines a records root with zero or more record elements. Each record must contain id, name and amount in that sequence. The identifier is a string, and amount is a decimal. The schema is an explicit example contract; it is not a format accepted by every XML importer.
Save the schema as a plain-text .xsd file. The prefix xs refers to the XML Schema vocabulary. The exported data elements in this example have no target namespace, so adding an unrelated default namespace to the result would change which elements the schema recognizes.
Create and fill the XML table
Enable the Developer tab, open Developer, Source and use XML Maps to add the schema. In the XML Source pane, map the repeating record’s fields to an XML table in the worksheet. Populate those mapped columns with the imported CSV values in the corresponding order.
Check the mapping rather than assuming that similar worksheet headings create it automatically. Microsoft’s XML overview explains how maps bind cells to elements. The element names in the map determine the exported XML names even if worksheet labels differ.
Export XML Data and inspect the result
Use Developer, Export and select the intended map when prompted. Choose a new XML destination. A structurally equivalent result for the example is:
<?xml version="1.0" encoding="UTF-8"?>
<records>
<record><id>00123</id><name>René</name><amount>12.5</amount></record>
<record><id>00999</id><name>North & East</name><amount>0</amount></record>
</records>The serialized XML may differ in indentation or decimal formatting. Under an xs:decimal contract, 12.50 and 12.5 represent the same numeric value. The identifier 00123 must retain its string characters, and the ampersand in North & East must be escaped in the XML serialization while decoding back to the original name.
Check mapping and export limitations
Excel XML Maps do not cover every schema construction or arbitrary nested data model. Multiple independent repeating lists and mixed-content documents can fail to map or fail to preserve their relationships. Microsoft’s export guidance describes these constraints and the XML export limit of 65,536 rows.
Do not treat a large export as complete without reconciling its record count. If the dataset or schema exceeds the mapping feature’s capabilities, use a converter designed for that schema. Changing the extension or selecting Spreadsheet XML does not remove those structural limitations.
Validate syntax, schema and values separately
First confirm that the output is well-formed XML. Then validate it against the intended XSD. Finally, compare the two record identifiers, names and decimal amounts with the CSV source. Schema validity checks structure and declared types; it does not prove that each name was associated with the correct identifier.
A missing amount or the text twelve would violate this example schema, while a wrong but syntactically valid amount could still pass. Use both structural validation and source reconciliation. Keep the source CSV, workbook and exact schema together so that a later export can be reproduced and checked under the same contract.


