---
title: "How to Export XML to Excel in 3 Easy Steps using C#?"
published_at: "2025-04-21T12:55:56+00:00"
modified_at: "2025-10-29T13:55:15+00:00"
url: "https://www.syncfusion.com/blogs/post/easily-export-xml-to-excel-in-csharp"
excerpt: "This blog explains how to export XML data to an Excel document in just 3 steps using our .NET Excel Library and C#."
taxonomy_category:
  - ".NET"
  - "C#"
  - "Data Visualization"
  - "Document Processing"
  - "Excel"
  - "Excel Library"
  - "File Formats"
  - "XlsIO"
taxonomy_post_tag:
  - "C#"
  - "Document Processing"
  - "Essential XlsIO"
  - "Excel"
  - "File Formats"
  - "XML"
---

# How to Export XML to Excel in 3 Easy Steps using C#?

[Mohan Chandran](https://www.syncfusion.com/blogs/author/mohan-chandran)

![How to Export XML to Excel in 3 Easy Steps using C#?](https://www.syncfusion.com/blogs/wp-content/uploads/2025/04/How-to-Export-XML-to-Excel-in-3-Easy-Steps-using-C.jpg)


**TL;DR:** Are you tired of manually converting XML to Excel? Save time and streamline your workflow with our .NET Excel Library (XlsIO)! In just 3 simple steps, you’ll learn how to export XML data to an Excel sheet using C#, apply XML mappings for structured data control, and export beautifully formatted Excel files—all with minimal code.

Working with XML data can be tedious, especially when you need to convert it into readable, shareable Excel spreadsheets. Manually copying data? Not scalable. Third-party tools? Often, they lack flexibility and control.

That’s where the Syncfusion® [.NET Excel Library](https://www.syncfusion.com/document-sdk/net-excel-library)
 (XlsIO) comes in. It lets you **seamlessly export XML files into Excel** with complete control over structure, formatting, and even mapping. Whether you’re building reports or transforming large datasets, XlsIO makes it easy.

The [.NET Excel Library](https://help.syncfusion.com/document-processing/excel/overview)
, also known as **Essential XlsIO**, is a robust tool that facilitates the smooth creation, reading, and editing of Excel documents using C#. It supports the creation of Excel documents from scratch, modification of existing Excel documents, data import and export, Excel formulas, conditional formats, data validations, charts, sparklines, tables, pivot tables, pivot charts, template markers, and much more.

This blog will explore the steps to export XML data to an Excel document using our .NET Excel Library and C#.


## Step 1: Create a .NET Core Console app

First, create a [.NET Core Console application](https://learn.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio?pivots=dotnet-8-0)
 in [Visual Studio](https://visualstudio.microsoft.com/)
, as shown in the following image.

![Create a .NET Core Console app using Visual Studio](https://www.syncfusion.com/blogs/wp-content/uploads/2025/04/Create-a-.NET-Core-Console-app-using-Visual-Studio.png)

## Step 2: Install the Syncfusion.XlsIO.NET.Core NuGet package

Then, install the latest [Syncfusion.XlsIO.NET.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core/)
 NuGet package in your app.

![Installing Syncfusion.XISIO.NET.Core NuGet Package](https://www.syncfusion.com/blogs/wp-content/uploads/2025/04/Installing-Syncfusion.XISIO_.NET_.Core-NuGet-Package.jpg)

## Step 3: Export XML data to an Excel document

Now, add the following code to Export XML data to an Excel document.

```
using Syncfusion.XlsIO;

namespace XmlToExcel
{
    class Program
    {
        public static void Main(string[] args)
        {
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Xlsx;

                IWorkbook workbook = application.Workbooks.Create(1);
                IWorksheet worksheet = workbook.Worksheets[0];

                // Import XML data into the worksheet
                FileStream inputStream = new FileStream(
                    "../../../Data/XmlFile.xml", FileMode.Open, FileAccess.Read);
                worksheet.ImportXml(inputStream, 1, 1);

                worksheet.UsedRange.AutofitColumns();

                // Saving the workbook as a stream
                FileStream outputStream = new FileStream(
                    "../../../Output/Output.xlsx", FileMode.Create, FileAccess.ReadWrite);
                workbook.SaveAs(outputStream);

                // Dispose streams
                inputStream.Dispose();
                outputStream.Dispose();
            }
        }
    }
}
```

Refer to the following images.

![Input XML data](https://www.syncfusion.com/blogs/wp-content/uploads/2025/04/Importing-XML-Data-into-Excel.jpg)

Input XML data

![Exporting XML data to an Excel document](https://www.syncfusion.com/blogs/wp-content/uploads/2025/04/Importing-XML-Data-into-an-Excel-document.png)

Exporting XML data to an Excel document


## XML maps to Excel

We can also add XML mapping to an Excel document using our .NET Excel Library. XML mapping enables us to define which parts of the XML data should be imported into Excel and which sections can be exported back as XML, offering complete control over your data transformation process.

To do so, please add the following code and run the app.

```
using Syncfusion.XlsIO;

namespace XmlMapToExcel
{
    class Program
    {
        public static void Main(string[] args)
        {
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Xlsx;
                IWorkbook workbook = application.Workbooks.Create(1);
                IWorksheet worksheet = workbook.Worksheets[0];

                // Import XML data into the worksheet
                FileStream inputStream = new FileStream("../../../Data/XmlFile.xml", FileMode.Open, FileAccess.Read);

                // Import XML mapping to Excel
                workbook.XmlMaps.Add(inputStream);

                // Saving the workbook as a stream
                FileStream outputStream = new FileStream("../../../Output/XmlMapOutput.xlsx", FileMode.Create, FileAccess.ReadWrite);
                workbook.SaveAs(outputStream);

                // Dispose stream
                inputStream.Dispose();
                outputStream.Dispose();
            }
        }
    }
}
```

Refer to the following image.

![XML mapping in Excel using .NET Excel Library](https://www.syncfusion.com/blogs/wp-content/uploads/2025/04/XML-mapping-in-Excel-using-.NET-Excel-Library.png)

The screenshot above shows that only the XML mapping is added to the Excel document. With XML maps, we can easily select and control the specific data to be imported or exported between the XML file and the Excel sheet.

## References

For more details, refer to the [Exporting XML to Excel using C# documentation](https://help.syncfusion.com/document-processing/excel/excel-library/net/import-export/import-to-excel#xml-data-to-excel)
 and [GitHub demo](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/XML%20to%20Excel)
.


## Conclusion

Thanks for reading! In this blog, we’ve explored how to export XML data to an Excel document using C# and Syncfusion [.NET Excel Library](https://www.syncfusion.com/document-sdk/net-excel-library)
**(XlsIO)**. It also allows you to export Excel data to [images](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-image/overview)
, [data tables](https://help.syncfusion.com/document-processing/excel/excel-library/net/import-export/export-from-excel#excel-to-datatable)
, [CSV](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-csv/overview)
, [HTML](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-html/overview)
, [collections of objects](https://help.syncfusion.com/document-processing/excel/excel-library/net/working-with-data)
, [ODS](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-ods/overview)
, [JSON](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-json/overview)
, and other file formats. Feel free to try out this versatile .NET Excel Library and share your feedback in the comments section of this blog post!

For current customers, our products are available on the [License and Downloads](https://www.syncfusion.com/sales/teamlicense)
 page. If you are new to Syncfusion, you can try our 30-day [free trial](https://www.syncfusion.com/downloads)
 to try them out.

Please let us know in the comments section below if you have any queries or require clarification. You can also contact us through our [support forums](https://www.syncfusion.com/forums)
, [support portal](https://support.syncfusion.com/)
, or [feedback portal](https://www.syncfusion.com/feedback/excel)
. We are always happy to assist you!


## Related Blogs



[Easily Convert Excel to HTML in 3 Steps With C#](https://www.syncfusion.com/blogs/post/easily-convert-excel-to-html-cshrap)



[How to Effectively Use Formulas in Excel Using C#](https://www.syncfusion.com/blogs/post/use-formulas-in-excel-using-csharp)



[Easily Create Dynamic Charts in Excel Using C#](https://www.syncfusion.com/blogs/post/dynamic-charts-in-excel-using-csharp)



[3 Easy Steps to Add Watermarks to Your Excel Document Using C#](https://www.syncfusion.com/blogs/post/add-watermarks-to-excel-in-csharp)
