In this article, I am going to share with you the method of converting an XML file to Excel in C#.Here, we are going to learn to read XML files in C# Windows.Form applications. We are going to make a small single-form application which takes an XML file from the user and converts that XML Data to Excel Data and returns an Excel file.Targeted AudienceThe targeted audience is people with basic knowledge of C#.ExplanationThings to do,. Make a C# WinForm application. Add a reference.

Convert Text File To Xml

Create UI. CodeCreate a new project and give it a suitable name as I gave the project name - ‘ConvertXmlToXl’.After creating the project, you have to add a reference named “Microsoft Excel Object library” in your project. You will find this reference in ‘COM’ Section.Now, make a UI which contains two Buttons, two Textboxes, one CheckBox, a single ProgressBar, and an OpenFileDialog tool. A button is used to browse the XML file and checkbox to give an option to the user for custom Excel file name.
C# Convert Class To Xml

And the ProgressBar is used to show the progress of the conversion. And, another button is for converting the XML file to Excel.So, here, our UI looks like the following.Now, code the click event of the button to browse the computer files so that the user can select the desired XML file.