ODS and Excel are two popular file formats used for storing and managing spreadsheet data. While both formats offer similar features, they are not always compatible with each other. This can create problems when sharing or collaborating on spreadsheet data with others who may not have access to ODS files. In such cases, converting ODS files to Excel format can be necessary. Converting ODS to Excel format also makes it easier to work with the data in Microsoft Excel, which is widely used in businesses and organizations. In this article, we will explore how to convert ODS to Excel using C# REST API and provide a comprehensive guide to help you successfully convert your files.
ODS to Excel Conversion API
Aspose.Cells Cloud SDK for .NET is a powerful API, offering a variety of features that make it easy to convert files while ensuring the quality and accuracy of the output. The SDK provides a range of conversion options, including converting ODS to XLS, ODS to XLSX, and other Excel formats. You can also specify the range of cells to be converted and apply formatting options to the output. Therefore, it is a great tool for anyone looking to convert ODS files to Excel format quickly and easily.
So in order to get started, please search Aspose.Cells-Cloud** in NuGet packages manager and click the Add Package button. Secondly, if you do not have an account over Cloud Dashboard, please create a free account by using a valid email address and obtain your personalized credentials.
ODS to Excel Converter using C#
In order to perform ODS to Excel conversion, we are going to use GetWorkbook API. Please take a look over the following code snippet.
Let’s understand the code snippet:
CellsApi cellsInstance = new CellsApi(clientID, clientSecret);
Create an object of CellsApi while passing client credentials as arguments.
var file = System.IO.File.OpenRead(input_ODS);
Read the content of input ODS to FileStream object.
var response = cellsInstance.CellsWorkbookPutConvertWorkbook(file, format:"XLSX", outPath:resultant_File);
Now in order to convert the ODS to Excel, call this API. The output format and name of the resultant file are provided as arguments to this method. After the conversion, the resultant XLSX is saved to cloud storage.
In order to test the conversion scenario, you may consider downloading the input input.ods file. For your reference, the resultant Excel generated in above example is uploaded over resultant.xlsx.
ODS to XLS using cURL Commands
Aspose.Cells Cloud can also be used with cURL commands to convert ODS files to Excel format. cURL is a popular command-line tool used for transferring data over various protocols, including HTTP, FTP, and others. Using cURL commands, you can easily convert your ODS files to Excel format without the need for any programming knowledge.
To get started, you will need to have cURL installed on your system and an Aspose.Cells Cloud account with an API key. Now generate an accessToken based on client credentials:
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Once you have accessToken, you can use the following cURL command to upload your ODS file to the cloud storage:
curl -v "https://api.aspose.cloud/v3.0/cells/storage/file/{filePath}" \
-X PUT \
-F file=@{localFilePath} \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer {accessToken}"
Replace
{filePath}
with the path where you want to store the file in the cloud storage,{localFilePath}
with the path of the ODS file on your local system, and{accessToken}
with your Aspose Cloud access token.
Once you have uploaded the file to the cloud storage, you need to use the following cURL command to convert the ODS file to Excel format:
curl -v "https://api.aspose.cloud/v3.0/cells/{name}?format=XLSX&isAutoFit=true&onlySaveTable=false&outPath=resultant.xlsx&checkExcelRestriction=true" \
-X GET \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}"
Replace
{name}
with the name of ODS file you uploaded to the cloud storage, and{accessToken}
with access token generated above. You can also specify the desired Excel format (e.g., XLS, XLSX) in theformat
parameter. After the conversion, the resultant Excel will be stored in same cloud storage.
Concluding Remarks
In this article, we have explored different methods to convert ODS files to Excel format using C# .NET and cURL commands. We discussed the need for ODS to Excel conversion and how it can help in collaborating and sharing spreadsheet data. We also looked at the features offered by Aspose.Cells Cloud SDK for .NET and how it can be used to convert ODS files to various Excel formats. Additionally, we learned how to use cURL commands with Aspose.Cells Cloud to convert ODS files to Excel format from the command line. These methods offer flexibility and convenience for anyone looking to convert ODS files to Excel format, whether they are familiar with programming or prefer a command-line interface.
Useful Links
Recommended Articles
Please visit the following links to learn more about: