Converting XLS to XLSX Format in Just 3 Steps Using C#
Tags: fileformats, csharp, excel, ui
Published: 2024-01-31 07:31:06

---
title: Converting XLS to XLSX Format in Just 3 Steps Using C#
published: true
date: 2024-01-24 11:57:09 UTC
tags: fileformats, csharp, excel, ui
canonical_url: https://www.syncfusion.com/blogs/post/convert-xls-to-xlsx-csharp.aspx
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1p89vcr5574kupg6sdwc.png
---
In today’s fast-paced technological landscape, staying up to date is crucial for seamless data management. The [XLS (Excel 97-2003) format](https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-xls/cd03cb5f-ca02-4934-a391-bb674cb8aa06 "Excel Binary File Format (.xls) Structure") has limited features compared to the latest [XLSX format](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-xlsx/2c5dee00-eff2-4b22-92b6-0738acd4475e "Excel (.xlsx) File Format"). Converting XLS documents to XLSX format will enable you to explore more features of Excel and avoid compatibility issues. This is where the Syncfusion [Excel Library](https://www.syncfusion.com/document-processing/excel-framework/net/excel-library ".NET Excel Library") becomes invaluable, allowing you to perform conversion easily.

The [Syncfusion Excel Library](https://help.syncfusion.com/file-formats/xlsio/overview "Getting started with Syncfusion Excel Library") , 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, import and export of data, Excel formulas, conditional formats, data validations, charts, sparklines, tables, pivot tables, pivot charts, template markers, and much more.

One of the key features of the Syncfusion Excel Library is its ability to open and convert **XLS files to XLSX format** with just a few lines of code.

Let’s see how to achieve this!

## Steps to convert XLS to XLSX format using C#

### Step 1: Create a new .NET Core console application

First, create a new [.NET Core console application](https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio "Create a new .NET Core console application in Visual Studio") in Visual Studio.

Refer to the following image.

### ![Create a .NET Core Console application in Visual Studio](https://www.syncfusion.com/blogs/wp-content/uploads/2024/01/Create-a-.NET-Core-Console-application-2.png)Step 2: Install and configure the Excel Library

Then, add the [Syncfusion.XlsIO.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core "Syncfusion.XlsIO.Net.Core NuGet package") NuGet package to your application.

### ![Install Syncfusion.XlsIO.Net.Core NuGet package](https://www.syncfusion.com/blogs/wp-content/uploads/2024/01/Install-Syncfusion.XlsIO_.Net_.Core-NuGet-package-1.png)Step 3: Convert XLS to XLSX format

Finally, implement the following code in the **Program.cs**  file to convert an XLS file to an XLSX document from a designated folder path.

```csharp
using Syncfusion.XlsIO;
using System.IO;

namespace ConvertXlsToXlsx
{
    class Program
    {
        private static string inputPath = @"../../../Data/";
        private static string outputPath = @"../../../Output/";

        static void Main(string[] args)
        {
            string fileName = "Report.xls";

            // Convert the Excel document
            ConvertXlsToXLSX(inputPath + fileName);
        }

        /// <summary>
        /// Convert the Excel document from the given path.
        /// </summary>
        /// <param name="filePath">Excel file path</param>
        private static void ConvertXlsToXLSX(string filePath)
        {
            FileStream inputData = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite);

            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Xlsx;
                IWorkbook workbook = application.Workbooks.Open(inputData);
                IWorksheets worksheets = workbook.Worksheets;

                workbook.Version = ExcelVersion.Xlsx;

                FileStream fileStream = new FileStream(outputPath + Path.GetFileNameWithoutExtension(filePath) + ".xlsx", FileMode.Create, FileAccess.ReadWrite);
                workbook.SaveAs(fileStream);
                fileStream.Close();
            }
        }
    }
}
```

Refer to the following image showing the input Excel document.
<figure>

  <img src="https://www.syncfusion.com/blogs/wp-content/uploads/2024/01/Input-Excel-document-6.png" alt="Input Excel document" style="width:100%">

  <figcaption>Input Excel document</figcaption>

</figure>

After executing the provided code example, the output document will resemble the following image.
<figure>

  <img src="https://www.syncfusion.com/blogs/wp-content/uploads/2024/01/Converting-XLS-to-XLSX-format-using-Syncfusion-Excel-Library-in-C.png" alt="Converting XLS to XLSX format using Syncfusion Excel Library in C#" style="width:100%">

  <figcaption>Converting XLS to XLSX format using Syncfusion Excel Library in C#</figcaption>

</figure>

**Note:** For more details, explore the [XLS features](https://help.syncfusion.com/file-formats/xlsio/supported-features-by-file-formats "Supported Features by File Formats") by Syncfusion Excel Library.

## References

You can download the example demonstrating the conversion of XLS files to XLSX documents in C# on our [GitHub demos](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Real%20Time%20Examples%20in%20Excel/ConvertXlsToXlsx "Converting XLS to XLSX Format using C# GitHub demo").

## Conclusion

Thanks for reading! In this blog, we explored how to convert XLS files to XLSX documents in C# with the [Syncfusion Excel Library](https://www.syncfusion.com/excel-framework/net ".NET Excel Library") **(XlsIO)**. With the Excel Library, you can also export Excel data to [PDF](https://help.syncfusion.com/file-formats/xlsio/excel-to-pdf-conversion "Excel to PDF Conversion"), [images](https://help.syncfusion.com/file-formats/xlsio/worksheet-to-image-conversion "Worksheet to Image conversion in Excel Library"), [data tables](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-data-table "Exporting from Worksheet to Data Table"), [CSV](https://www.syncfusion.com/kb/9092/convert-excel-file-to-csv-in-c-vb-net "KB: Convert Excel file to CSV in C#, VB.NET"), [TSV](https://www.syncfusion.com/kb/8556/does-xlsio-support-tsv-files "KB: Does XlsIO support TSV files?"), [HTML](https://help.syncfusion.com/file-formats/xlsio/working-with-excel-worksheet?_ga=2.19528508.561950334.1598519523-255771547.1598519523#save-worksheet-as-html "Save Worksheet as HTML"), [collections of objects](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-clr-objects "Working with Excel Data"), [ODS](https://help.syncfusion.com/file-formats/xlsio/excel-to-ods-conversion "Excel to ODS Conversion") , [JSON](https://help.syncfusion.com/file-formats/xlsio/excel-to-json-conversion "Excel to JSON Conversion"), and more file formats.

Take a moment to peruse the [import data](https://help.syncfusion.com/file-formats/xlsio/working-with-data#importing-data-to-worksheets "Importing Data to Worksheets") documentation, where you’ll discover additional importing options and features such as [data tables](https://help.syncfusion.com/file-formats/xlsio/working-with-data#import-data-from-datatable "Import Data from DataTable"), [collection objects](https://help.syncfusion.com/file-formats/xlsio/working-with-data#import-data-from-collection-objects "Import Data from Collection Objects"), [grid view](https://help.syncfusion.com/file-formats/xlsio/working-with-data#import-data-from-dataview "Import Data from DataView"), [data columns](https://help.syncfusion.com/file-formats/xlsio/working-with-data#import-data-from-datacolumn "Importing Data from DataColumn"), and [HTML](https://help.syncfusion.com/file-formats/xlsio/working-with-data#importing-html-table-to-excel-worksheet "Importing HTML Table to Excel Worksheet"), all accompanied by code samples. 

Feel free to try out these methods and share your feedback in the comments section of this blog post! 

For existing customers, the new version of Essential Studio is available for download from the [License and Downloads](https://www.syncfusion.com/account/downloads "Essential Studio License and Downloads page") page. If you are not yet a Syncfusion customer, you can try our 30-day [free trial](https://www.syncfusion.com/downloads "Get the free 30-day evaluation of Essential Studio products") to check out our available features.

For questions, you can contact us through our [support forum](https://www.syncfusion.com/forums "Syncfusion Support Forum"), [support portal](https://support.syncfusion.com/ "Syncfusion Support Portal"), or [feedback portal](https://www.syncfusion.com/feedback/excel "Syncfusion Feedback Portal"). We are happy to assist you!

## Related blogs

- [Merge Multiple Excel Files into One in Just 3 Steps Using C#](https://www.syncfusion.com/blogs/post/merge-multiple-excel-csharp.aspx "Blog: Merge Multiple Excel Files into One in Just 3 Steps Using C#")
- [6 Easy Ways to Export Data to Excel in C#](https://www.syncfusion.com/blogs/post/6-easy-ways-to-export-data-to-excel-in-c-sharp.aspx "Blog: 6 Easy Ways to Export Data to Excel in C#")
- [Seamlessly Import and Export CSV Data in Excel Using C#](https://www.syncfusion.com/blogs/post/import-export-csv-data-in-excel-csharp.aspx "Blog: Seamlessly Import and Export CSV Data in Excel Using C#")
- [How to Export Data from SQL Server to an Excel Table in C#](https://www.syncfusion.com/blogs/post/export-data-from-sql-server-to-excel-in-c-sharp.aspx "Blog: How to Export Data from SQL Server to an Excel Table in C#")
- [Export Data from a Collection to Excel and Group It in C# ](https://www.syncfusion.com/blogs/post/export-data-from-collection-to-excel-and-group-csharp.aspx "Blog: Export Data from a Collection to Excel and Group It in C#")
- [Export Data to a Predefined Excel Template in C#](https://www.syncfusion.com/blogs/post/export-data-to-a-predefined-excel-template-in-c.aspx "Blog: Export Data to a Predefined Excel Template in C#")
- [Easy Steps to Export HTML Tables to Excel in C#](https://www.syncfusion.com/blogs/post/easy-steps-to-export-html-tables-to-an-excel-worksheet-in-c.aspx "Blog: Easy Steps to Export HTML Tables to Excel in C#")