Converting XLS to XLSX Format in Just 3 Steps Using C#
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (173).NET Core  (29).NET MAUI  (206)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (40)Black Friday Deal  (1)Blazor  (214)BoldSign  (14)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (66)Flutter  (132)JavaScript  (220)Microsoft  (118)PDF  (81)Python  (1)React  (100)Streamlit  (1)Succinctly series  (131)Syncfusion  (911)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (50)Windows Forms  (61)WinUI  (68)WPF  (158)Xamarin  (161)XlsIO  (36)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (147)Chart  (130)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (624)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (40)Extensions  (22)File Manager  (6)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (504)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (386)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (588)What's new  (329)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Converting XLS to XLSX Format in Just 3 Steps Using C#

Converting XLS to XLSX Format in Just 3 Steps Using C#

In today’s fast-paced technological landscape, staying up to date is crucial for seamless data management. The XLS (Excel 97-2003) format has limited features compared to the latest XLSX 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 becomes invaluable, allowing you to perform conversion easily.

The 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!

Enjoy a smooth experience with Syncfusion’s Excel Library! Get started with a few lines of code and without Microsoft or interop dependencies.

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 in Visual Studio.

Refer to the following image.

Create a .NET Core Console application in Visual Studio

Handle Excel files like a pro with Syncfusion’s C# Excel Library, offering well-documented APIs for each functionality.

Step 2: Install and configure the Excel Library

Then, add the Syncfusion.XlsIO.Net.Core NuGet package to your application.

Install Syncfusion.XlsIO.Net.Core NuGet package

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.

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.

Input Excel document
Input Excel document

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

Converting XLS to XLSX format using Syncfusion Excel Library in C#
Converting XLS to XLSX format using Syncfusion Excel Library in C#

Note: For more details, explore the XLS features 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.

Don't settle for ordinary spreadsheet solutions. Switch to Syncfusion and upgrade the way you handle Excel files in your apps!

Conclusion

Thanks for reading! In this blog, we explored how to convert XLS files to XLSX documents in C# with the Syncfusion Excel Library (XlsIO). With the Excel Library, you can also export Excel data to PDF, images, data tables, CSVTSVHTMLcollections of objectsODS , JSON, and more file formats.

Take a moment to peruse the import data documentation, where you’ll discover additional importing options and features such as data tablescollection objectsgrid viewdata columns, and HTML, 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 page. If you are not yet a Syncfusion customer, you can try our 30-day free trial to check out our available features.

For questions, you can contact us through our support forumsupport portal, or feedback portal. We are happy to assist you!

Related blogs

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed