It can be achieved by using Microsoft.Office.Interop.Excel as shown below:

First of all declare these necessary references.

using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.Office.Tools.Excel;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using System.Diagnostics;
using Microsoft.Win32;

Than create excel app as shown:

Excel.Application excel2; // Create Excel app
Excel.Workbook DataSource; // Create Workbook
Excel.Worksheet DataSheet; // Create Worksheet
excel2 = new Excel.Application(); // Start an Excel app
DataSource = (Excel.Workbook)excel2.Workbooks.Add(1); // Add a Workbook inside
string tempFolder = System.IO.Path.GetTempPath(); // Get folder 
string FileName = openFileDialog1.FileName.ToString(); // Get xml file name

After that use below code in a loop to ensure all items in xml file are copied

// Open that xml file with excel
DataSource = excel2.Workbooks.Open(FileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
// Get items from xml file
DataSheet = DataSource.Worksheets.get_Item(1);
// Create another Excel app as object
Object xl_app;
xl_app = GetObj(1, "Excel.Application");
Excel.Application xlApp = (Excel.Application)xl_app;
// Set previous Excel app (Xml) as ReportPage
Excel.Application ReportPage = (Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
// Copy items from ReportPage(Xml) to current Excel object
Excel.Workbook Copy_To_Excel = ReportPage.ActiveWorkbook;

Now we have an Excel object named as Copy_To_Excel that contains all items in Xml.. We can save and close the Excel object with the name we want..

Copy_To_Excel.Save("thePath\theFileName");
Copy_To_Excel.Close();
Answer from John on Stack Overflow
🌐
Microsoft Support
support.microsoft.com › en-us › office › import-xml-data-6eca3906-d6c9-4f0d-b911-c736da817fa4
Import XML data - Microsoft Support
If you're using Excel 2016 or earlier, click Data > From Other Sources > From XML Data Import. Go to the drive, folder, or Internet location that has the XML data file (.xml) you want to import.
Discussions

Transform XML data in excel
I have an xml file that when I import in to excel presents the data as such Fieldname1A2B3C4A5B6C7A8B9CHow can I transform this to ABC123456789 More on learn.microsoft.com
🌐 learn.microsoft.com
5
0
April 16, 2025
Convert xml to excel/csv
Please help me in converting XML file into excel/csv. Thank you in advance. More on discuss.python.org
🌐 discuss.python.org
0
0
October 15, 2022
c# - How to convert xml to excel file programmatically - Stack Overflow
I have a xml document holding a small data for my project where I want to convert my xml to an excel file (microsoft office excel 2003 and over) How can I do this programmatically? More on stackoverflow.com
🌐 stackoverflow.com
Quick convert XML to Excel - Stack Overflow
What is the quickest (as in least effort, not super performance) way to convert 112K rows in XML to a Excel view. More on stackoverflow.com
🌐 stackoverflow.com
People also ask

Can XML file be converted to Excel?
Yes, this is easy with our unique Free XML to Excel Online Converter.
Steps to Convert XML to Excel:
  • Upload XML file
  • Click 'Run Conversion' button
  • When the file is converted - download Excel file
🌐
conversiontools.io
conversiontools.io › convert › xml-to-excel
XML file to Excel Converter Online | Convert XML to spreadsheet
How do I open an XML file in Excel?
First, convert XML to Excel format using our Free XML to Excel Online Converter.
Steps to use XML to Excel Converter:
  • Upload XML file
  • Click 'Run Conversion' button
  • When the file is converted - download Excel file
  • Open Excel file in Microsoft Excel
🌐
conversiontools.io
conversiontools.io › convert › xml-to-excel
XML file to Excel Converter Online | Convert XML to spreadsheet
🌐
Kaltura
knowledge.kaltura.com › help › how-to-convert-an-xml-document-to-csv-file-or-excel-spreadsheet
Convert API XML output to CSV or Excel | Kaltura Knowledge Center
Choose where to save the file and click Save. OpenExceland clickFilein the ribbon bar. ChooseOpen, thenBrowseto locate the file saved in the previous step. Select the file and clickOpen. A pop-up box displays. Choose As an XML table and click OK.
🌐
Conversion Tools
conversiontools.io › convert › xml-to-excel
XML file to Excel Converter Online | Convert XML to spreadsheet
We accept any well-formed XML file regardless of schema or structure. The converter supports all character encodings, with UTF-8 being the most common. Large XML files are processed efficiently. XLSX (default): Modern Excel format for Office 2007 and later. Supports up to 1,048,576 rows and 16,384 columns.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 5450821 › transform-xml-data-in-excel
Transform XML data in excel - Microsoft Q&A
April 16, 2025 - Select your XML file and import it. Once the data is loaded in a table format, click on Transform Data to open Power Query. Select the "Field" column. Click Transform → Pivot Column.
Find elsewhere
🌐
Alteryx Community
community.alteryx.com › t5 › Alteryx-Designer-Desktop-Discussions › XML-to-Excel › td-p › 1162329
Solved: XML to Excel - Alteryx Community
December 14, 2023 - If you are wanting to get the xml into Excel with each line of code on a separate row, you can use the top method in the workflow. If you'd like to see all of the code in a single cell, you can use the second output in the workflow. This, however, will only work with small xml files due to Excel's character limit in a cell.
🌐
Python.org
discuss.python.org › python help
Convert xml to excel/csv - Python Help - Discussions on Python.org
October 15, 2022 - Please help me in converting XML file into excel/csv. Thank you in advance.
Top answer
1 of 8
6

It can be achieved by using Microsoft.Office.Interop.Excel as shown below:

First of all declare these necessary references.

using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.Office.Tools.Excel;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using System.Diagnostics;
using Microsoft.Win32;

Than create excel app as shown:

Excel.Application excel2; // Create Excel app
Excel.Workbook DataSource; // Create Workbook
Excel.Worksheet DataSheet; // Create Worksheet
excel2 = new Excel.Application(); // Start an Excel app
DataSource = (Excel.Workbook)excel2.Workbooks.Add(1); // Add a Workbook inside
string tempFolder = System.IO.Path.GetTempPath(); // Get folder 
string FileName = openFileDialog1.FileName.ToString(); // Get xml file name

After that use below code in a loop to ensure all items in xml file are copied

// Open that xml file with excel
DataSource = excel2.Workbooks.Open(FileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
// Get items from xml file
DataSheet = DataSource.Worksheets.get_Item(1);
// Create another Excel app as object
Object xl_app;
xl_app = GetObj(1, "Excel.Application");
Excel.Application xlApp = (Excel.Application)xl_app;
// Set previous Excel app (Xml) as ReportPage
Excel.Application ReportPage = (Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
// Copy items from ReportPage(Xml) to current Excel object
Excel.Workbook Copy_To_Excel = ReportPage.ActiveWorkbook;

Now we have an Excel object named as Copy_To_Excel that contains all items in Xml.. We can save and close the Excel object with the name we want..

Copy_To_Excel.Save("thePath\theFileName");
Copy_To_Excel.Close();
2 of 8
3

you can even read the XML file as string and use regular expressions to read the content between the tags and create a CSV file or use xpath expressions to read the XML file data and export to CSV file.

Top answer
1 of 5
28

Why so complicated? Just open the File with File->Open choose xml and load it. See what'll happen.

2 of 5
6

If you're using Excel 2007 and want to use XSLT, your best bet would probably be use the EXPath Zip Module features to modify an existing Excel .xslx file.

My preferred option, however, would be to use a small Excel VBA Macro.

I've included sample code below for a VBA procedure called 'load' - this sample uses the XML DOM, so all 112K rows of your XML will be first loaded into memory, but if performance isn't an issue its simpler than the SAX alternative.

You would need to modify xpathToExtractRow to suit your XML input structure. There is also an assumption that the immediate child nodes of the XML row element contain the cell data you wish to import as text nodes, if not, you will need to use a SelectNode call to get the data you require.

Private dom As DOMDocument60

Public Sub load()

Dim nodeList As IXMLDOMNodeList
Dim nodeRow As IXMLDOMNode
Dim nodeCell As IXMLDOMNode
Dim rowCount As Integer
Dim cellCount As Integer
Dim rowRange As Range
Dim cellRange As Range
Dim sheet As Worksheet

Dim xpathToExtractRow As String
xpathToExtractRow = "/feed/row"

Set dom = New DOMDocument60
dom.load ("c:\test\source.xml")
Set sheet = ActiveSheet
Set nodeList = dom.SelectNodes(xpathToExtractRow)

rowCount = 0
For Each nodeRow In nodeList
    rowCount = rowCount + 1
    cellCount = 0
    For Each nodeCell In nodeRow.ChildNodes
        cellCount = cellCount + 1
        Set cellRange = sheet.Cells(rowCount, cellCount)
        cellRange.Value = nodeCell.Text
    Next nodeCell
Next nodeRow

End Sub

Sample Input XML:

<?xml version="1.0" encoding="utf-8"?>
<feed>
  <row>
    <firstname>joe</firstname>
    <lastname>smith</lastname>
    <country>jamaica</country>
  </row>
  <row>
    <firstname>bill</firstname>
    <lastname>coots</lastname>
    <country>uk</country>
  </row>
</feed>
🌐
MaxAI
maxai.co › file-tools › excel-to-xml
Excel to XML - Convert a Excel to XML Online for Free | MaxAI
Convert Excel to XML online for free. Effortlessly transform your Excel data to XML format for seamless integration and compatibility. No file size limits, downloads, or sign-ups required.
🌐
Washington Department of Financial Institutions
dfi.wa.gov › sites › default › files › convert-excel-xml-file.pdf pdf
1 | P a g e Converting Excel file to XML file
Before we start preparing the excel ... and Excel templates · to your computer where you can easily access them. XSD Schemas are required for mapping and converting ... Steps below will walk you through the process. 1. Here, we’re creating an AAR Make Real Estate XML ...
🌐
Udemy
blog.udemy.com › home › how to convert data in excel to xml in 7 easy steps
How To Convert Data in Excel to XML in 7 Steps - Udemy Blog
October 24, 2025 - It’s widely used across the internet and in many software environments. You can convert XML to Excel by using Excel’s built-in “Get Data” feature or the “Import” button on the Developer tab.
🌐
Excel Easy
excel-easy.com › examples › xml.html
Convert XML to Excel - Step by Step Tutorial
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <data-set xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <record> <LastName>Smith</LastName> <Sales>16753</Sales> <Country>UK</Country> <Quarter>Qtr 3</Quarter> </record> <record> <LastName>Johnson</LastName> <Sales>14808</Sales> <Country>USA</Country> <Quarter>Qtr 4</Quarter> </record> </data-set> Note: the tags refer to the column names, but you can give them any name you want!
🌐
ConvertCSV
convertcsv.com › xml-to-csv.htm
XML To CSV Converter
Convert XML to CSV and XML to Excel Spreadsheet
🌐
Microsoft Power Platform
community.powerplatform.com › forums › thread › details
Using Power Automate Desktop to convert XML files to Excel ...
June 25, 2021 - Hi, I wanted to see if there is a way to convert XML files in a folder to the Excel files using Power Automate desktop. I see there is a way to iterate over files in a folder and read XML. What I seem to be missing is a way to convert XML to Excel/ write XML data to Excel.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1588592 › excel-or-csv-file-to-xml-adf
Excel or CSV file to XML - ADF - Microsoft Q&A
February 25, 2024 - import pandas as pd import xml.etree.ElementTree as ET # Load the Excel/CSV file df = pd.read_csv('path_to_your_file.csv') # Convert the DataFrame to XML format root = ET.Element("Root") for _, row in df.iterrows(): record = ET.SubElement(root, "Record") for col in df.columns: child = ET.SubElement(record, col) child.text = str(row[col]) # Convert the XML tree to a string xml_str = ET.tostring(root, encoding='utf8', method='xml') # Save or use the XML string as needed
🌐
Microsoft Support
support.microsoft.com › en-us › office › export-xml-data-0b21f51b-56d6-48f0-83d9-a89637cd4360
Export XML data - Microsoft Support
This dialog box only appears if an XML table isn't selected and if the workbook has more than one XML Map. In the large Export XML dialog box, in the File name box, type a name for the XML data file. Click Export. Note: If your worksheet has headings or labels that are different from the XML ...