Converting Excel files to OpenDocument Spreadsheet formats like ODS and FODS is valuable for ensuring compatibility with open-source applications such as LibreOffice and OpenOffice. These formats are designed to be widely accessible, giving users more flexibility and freedom in how they handle spreadsheet data. In this guide, we’ll walk through how to convert an Excel file to both ODS and FODS formats in C#.
The following headings explain Excel conversions further:
- Why Convert Excel to OpenDocument Spreadsheet?
- Excel to OpenDocument - C# API Configuration
- Convert Excel to ODS in C#
- Convert XLSX to FODS in C#
Why Convert Excel to OpenDocument Spreadsheet?
Converting Excel files to ODS and FODS formats offers several benefits:
Enhanced Compatibility: ODS and FODS are supported by open-source platforms, allowing easy access across various software.
Cross-Platform Accessibility: These formats ensure that users on different operating systems can view and edit spreadsheet files without needing proprietary software.
Data Portability: ODS and FODS are part of the OpenDocument format family, which is standardized and ideal for long-term data storage and exchange.
Excel to OpenDocument - C# API Configuration
For converting Excel worksheets to ODS or FODS file format, you need to install Conholdate.Total for .NET using the following NuGet installation command:
PM> NuGet\Install-Package Conholdate.Total
Convert Excel to ODS in C#
The OpenDocument Spreadsheet (ODS) format is widely used in open-source applications like LibreOffice Calc. Converting an Excel file to ODS format in C# is simple and efficient with the following steps:
- Load the Workbook: The Workbook class loads the Excel file that you want to convert.
- Save as ODS: Using the Save method, the workbook is saved in ODS format, making it accessible in OpenDocument-compliant software.
The following code snippet demonstrates how to convert Excel to ODS in C#:
// Load your source workbook | |
Workbook workbook = new Workbook("input.xlsx"); | |
// Save as ODS file | |
workbook.Save("output.ods"); |
This quick approach allows you to convert Excel files to ODS format effortlessly, ensuring compatibility with open-source applications.
Convert XLSX to FODS in C#
The Flat OpenDocument Spreadsheet (FODS) format is an XML-based version of the ODS format, allowing users to work with a single file instead of multiple compressed files. Here’s how to convert an Excel file to FODS format in C#.
- Load the Workbook: Similar to the previous section, we load the Excel file with the Workbook class.
- Save as FODS: By specifying the .fods extension in the Save method, the workbook is converted to FODS format.
The sample code below shows how to convert XLSX to FODS in C#:
// Load your source workbook | |
Workbook workbook = new Workbook("input.xlsx"); | |
// Save as FODS file | |
workbook.Save("output.fods"); |
Converting to FODS format is especially useful for users who prefer XML-based file structures, allowing for easier file parsing and manipulation in open-source environments.
Get a Free License
You may get a free temporary license to evaluate various features offered by the API without any watermark or restrictions.
Summing up
Converting Excel files to OpenDocument Spreadsheet formats (ODS and FODS) in C# offers a practical way to make data more accessible and compatible with various applications. These conversions are straightforward, providing flexibility to developers who need cross-platform data solutions. Whether for interoperability with open-source tools or standardized data exchange, converting Excel files to ODS and FODS formats can simplify workflows and enhance document accessibility. If you need to discuss any concerns or questions, please write to us at the forum.