Skip to content

Instantly share code, notes, and snippets.

@groupdocs-cloud-gists
Last active February 18, 2025 17:38
Show Gist options
  • Save groupdocs-cloud-gists/f2997d20c63864823da8715fe24c1cba to your computer and use it in GitHub Desktop.
Save groupdocs-cloud-gists/f2997d20c63864823da8715fe24c1cba to your computer and use it in GitHub Desktop.
Convert ODS to Excel in .NET
Learn how to perform ODS to Excel worksheet conversion using C# .NET.
// More examples over https://github.com/groupdocs-conversion-cloud/groupdocs-conversion-cloud-dotnet
// Obtain your API credentials
string clientId = "XXXXXX-XXXXXXXXX-4088-9ca0-55c38f4b7f22";
string clientSecret1 = "XXXXXXXXXXXXXXXXXXXX";
// Create an instance of the Configuration class and initialize it with the Client ID & Client Secret.
var configurations = new Configuration(clientId, clientSecret1);
// Define the value of ApiBaseUrl to set the base url for ODS to Excel conversion API.
configuration.ApiBaseUrl = "https://api.groupdocs.cloud";
// Initialize an instance of the ConvertApi class with an object of Configuration class.
var apiInstance = new ConvertApi(configurations);
// load the input ODS file from local drive
using (var stream = System.IO.File.OpenRead("input.ods"))
{
// create an instance of FileApi
var fileUpload = new FileApi(configurations);
// upload the input ODS to the cloud storage
fileUpload.UploadFile(new UploadFileRequest("input.ods", stream));
// create ConvertSettings where we specify the name of input ODS and the name for resultant XLS file.
var settings = new ConvertSettings
{
StorageName = "default",
FilePath = "input.ods",
Format = "xls",
OutputPath = "converted.xls"
};
// Invoke the ConvertDocument method for ODS to Excel conversion operation.
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
if (response != null && response.Equals("OK"))
{
// print success message
Console.WriteLine("The ODS to Excel conversion completed successfully !");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment