Excel, developed by Microsoft, is a widely used spreadsheet application that offers a range of features for data analysis, visualization, and management. ODS (OpenDocument Spreadsheet), on the other hand, is an open standard format for spreadsheets, which means it can be read and edited by various software applications, including LibreOffice and Apache OpenOffice.
Converting between these two formats can be necessary for compatibility, sharing, or specific feature requirements. In this article, you will learn how to convert Excel to ODS or OSD to Excel in C# using Spire.XLS for .NET.
Install Spire.XLS for .NET
To begin with, you need to add the DLL files included in the Spire.XLS for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.XLS
Convert Excel to ODS (OpenDocument Spreadsheet) in C#
You can load an Excel (.xls or .xlsx) file and then save it as an ODS file through the Workbook.SaveToFile(string fileName, FileFormat.ODS) method. The following are the detailed steps:
- Create a Workbook instance.
- Load an Excel file using Workbook.LoadFromFile() method.
- Save the Excel file to ODS format using Workbook.SaveToFile(string fileName, FileFormat.ODS) method.
- C#
using Spire.Xls; namespace ConvertExcelToODS { class Program { static void Main(string[] args) { // Create Workbook instance Workbook workbook = new Workbook(); // Load an Excel file workbook.LoadFromFile("Sample.xlsx"); // Save the Excel to ODS file workbook.SaveToFile("ToODS.ods", FileFormat.ODS); } } }
Convert ODS to Excel (XLS/XLSX) in C#
Spire.XLS for .NET also supports converting an ODS file back to Excel XLS or XLS format. The following are the detailed steps:
- Create a Workbook instance.
- Load an ODS file using Workbook.LoadFromFile() method.
- Save the ODS file in XLS or XLSX format using Workbook.SaveToFile(string fileName, FileFormat fileFormat) method.
- C#
using Spire.Xls; namespace ODSToExcel { class Program { static void Main(string[] args) { // Create Workbook instance Workbook workbook = new Workbook(); // Load an ODS file workbook.LoadFromFile("ToODS.ods"); // Save the ODS file in XLSX format workbook.SaveToFile("ToExcel.xlsx", FileFormat.Version2016); // Save the ODS file in XLS format workbook.SaveToFile("ToExcel.xls", FileFormat.Version97to2003); } } }
Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.