How to convert an Excel XLSX to a PNG Array in C# .NET Framework

Cloudmersive
1 min readJul 25, 2020

--

Converting an Excel file into a set of PNGs is actually quite a tall order when work with C#. Parsing the Excel file, for one, is not an easy task. Then comes a string of annoyances in the form of rasterization, rendering, etc. If you would like to avoid all of this mess, there is a much easier solution that will you have up and converting in no time at all.

To get started, we will need to install our package using this command for NuGet:

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

Next we can call our function for converting XLSX to PNG:

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 ConvertDocumentXlsxToPngExample{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 Excel XLSX spreadsheet to PNG image arrayXlsxToPngResult result = apiInstance.ConvertDocumentXlsxToPng(inputFile);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentXlsxToPng: " + e.Message );}}}}

And that’s really all that you have to do. You can now create images from XLSX files to your heart’s content.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet