Excel has the option to export the schema. However, there are many cases where it will not function. https://support.microsoft.com/en-us/office/export-xml-data-0b21f51b-56d6-48f0-83d9-a89637cd4360#Common%20issues%20with%20exporting%20XML%20data
I did find a workaround. If you open the excel file as an archive with 7-zip or similar tool it contains a file called xmlMaps.xml. The file contains all the xml maps for the document. Use a text editor to save each schema in a separate xsd file.
Answer from CodeMonkey on Stack Overflowxml - How do I save a schema definition XSD file from Excel 2016? - Stack Overflow
XML schema for Excel XML exportation - Stack Overflow
xml - Generate XSD file from MS Excel file definition - Stack Overflow
Existing XML Schema for excel
Videos
Note: there is no solution using just Excel.
This was true in 2013 when the OP asked the question, and is still true now, as far as I can tell.
The answers provided on this page, though they use external tooling, represent the only solutions on the internet at this time, and have since been viewed 13,000 times.
If you or anyone you know have a solution using only Excel to generate XSD, please add it, because this is clearly something that would help many people.
Model the class in code:
public class Something
{
public int ID { get; set; }
public string First_Name { get; set; }
public string Last_Name { get; set; }
public string Phone_number { get; set; }
}
Save it to a .cs file and then compile it.
and then use xsd.exe to generate the xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Something" nillable="true" type="Something" />
<xs:complexType name="Something">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="ID" type="xs:int" />
<xs:element minOccurs="0" maxOccurs="1" name="First_Name" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Last_Name" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Phone_number" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
In notepad, write your new schema like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <data-set xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <record> <ID>12345</ID> <FirstName>First Name</FirstName> <LastName>Last Name</LastName> <PhoneNumber>555-555-5555</PhoneNumber> </record> <record> <ID>12346</ID> <FirstName>John</FirstName> <LastName>Doe</LastName> <PhoneNumber>555-555-5555</PhoneNumber> </record> </data-set>Save the file as schema.xml
- Open your excel file.
- On the Developer tab, open the XML Source task pane.
- To add an XML map, click XML Maps

- Click Add
- Select schema.xml and click OK twice
- Now simply drag (map) the 4 elements from the tree onto the worksheet (row 1). Image shows the first two done.

- On the Developer tab, under the XML group, click Export.
- Save your file as data-set.xml and press Enter.
Result will look like this:
