How to Convert ODS to PNG in C# .Net Framework

Today is your lucky day. Why? Because this article is going to save your bacon. The process by which a document file is converted into an image is a long and painful one, full of parsing quirks and other lovely little bugs. Today’s post will dive straight past the entire mess and provide you with the result you need, right this very minute.

To begin, we are going to go ahead and retrieve our library using NuGet.

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.2.8

Once we have that, we can create our function call for ODS to PNG array:

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class ConvertDocumentOdsToPngExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new ConvertDocumentApi();var inputFile = new System.IO.Stream(); // System.IO.Stream | Input file to perform the operation on.try{// Convert ODS Spreadsheet to PNG image arrayOdsToPngResult result = apiInstance.ConvertDocumentOdsToPng(inputFile);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentOdsToPng: " + e.Message );}}}}

And wow, we are already done.

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.