How to convert Legacy XLS (97–03) Spreadsheet to PDF in C# .Net Framework

There really isn’t a practical place for out of date file formats in your business. That is why today we will be going step by step through a process for setting up file conversion between legacy XLS format from 2003 and nicely convenient PDF. If you would instead rather update your XLS to XLSX or CSV, we have a separate tutorial for that.

Let’s get started with our process. We begin by installing our client — simply run this command from the Package Manager console:

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

Now that we have our client, we can call the ConvertDocumentXlsToPdf function from it, as follows:

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 ConvertDocumentXlsToPdfExample{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 XLS (97-03) Spreadsheet to PDFbyte[] result = apiInstance.ConvertDocumentXlsToPdf(inputFile);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentXlsToPdf: " + e.Message );}}}}

This function will handle our conversion between formats, so that’s really all there is to it.

Image for post
Image for post

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store