This post will walk you through the step-by-step instructions to convert XLS to XLSX using C#. We will also use the detailed instructions to convert documents and generate XLSX from XLS using C#. These instructions and example code are compatible with .NET-based systems such as Microsoft Windows, Linux, and macOS.
Steps to Convert XLS to XLSX using C#
- Setup GroupDocs.Conversion for .NET package from NuGet.org website
- Add a reference to the GroupDocs.Conversion namespace to consume API calls in the code for performing document conversion
- Load the input XLS file by creating an instance of the Converter class
- Initialize SpreadsheetConvertOptions class by creating an object of it
- Save the converted XLSX file to the disk by calling the Convert method of the Converter class
The above steps for implementing the C# convert XLS to XLSX feature are fairly straightforward. Download the appropriate package from NuGet and include the relevant namespace in the code to begin the document conversion. After that, load the source XLS file by constructing a Converter object, and define the convert options for the output XLSX file by creating an instance of the SpreadsheetConvertOptions class. Finally, use the Convert function to save the transformed file to a disc.
Code to Convert XLS to XLSX using C#
To demonstrate how to use this guide, we have created the above sample C# code to convert XLS to XLSX. You may take this example code as a starting point for your project and easily customize it by using the SpreadsheetConvertOptions class to set the various output document characteristics. You can also convert an XLS file to other document formats such as XLAM, XLTM, XLSB, JPG, TIFF, SVG, and many others.
We described the detailed instructions to convert XLS to XLSX in C# capability and created sample code in this article. In our recent article, we looked on how to convert XML to CSV in C#; have a look at it for more information.