excel to pdf

Excel to PDF converter using C# .NET.

Excel spreadsheets have become a cornerstone of data organization and analysis for businesses and individuals alike. However, there are numerous instances where sharing or presenting this data in a more universal and accessible format becomes necessary. This is where the need for converting Excel workbooks to PDF arises. The reason of selecting PDF format is because, it offers a standardized format that preserves the layout, formatting, and content of the original spreadsheet, ensuring consistency across different devices and platforms. In this article, we are going to explore the benefits and necessity of Excel to PDF conversion and guide you through this conversion process using C# .NET.

This article is covering following topics:

Excel Workbook to PDF Conversion SDK

With GroupDocs.Conversion Cloud SDK for .NET, the conversion of Excel workbooks to PDF format becomes a straightforward and efficient process. This SDK provides you a comprehensive set of tools and APIs, allowing them to seamlessly integrate document conversion capabilities into your applications. Additionally, the SDK offers advanced features such as customizable conversion settings, batch processing, and support for various Excel formats (XLS and XLSX), providing users with flexibility and control over the conversion process.

First we need to install the SDK in our .NET solution. Therefore, search GroupDocs.Conversion-Cloud in NuGet package manager and click the Install button. Another option is to execute the following command in package manager console.

NuGet\Install-Package GroupDocs.Conversion-Cloud -Version 24.2.0

Once the SDK is successfully installed, make sure you have the API credentials(i.e. Client ID and Client Secret). You may visit this short tutorial explaining the details on how to get the API credentials.

XLS to PDF in C# .NET

In this section, we are going to utilize GroupDocs.Conversion Cloud SDK for .NET, where you can streamline document management workflows, enhance collaboration, and deliver seamless Excel to PDF conversion capabilities using C# .NET.

  1. Create an instance of Configuration class where we pass client credentials as arguments.
var configurations = new Configuration(clientId, clientSecret1);
  1. Initialize the ConvertApi where we pass Configuration object as an input argument.
var apiInstance = new ConvertApi(configurations);
  1. Upload the input Excel workbook to the cloud storage.
fileUpload.UploadFile(new UploadFileRequest("input.xls", stream));
  1. Create an instance ConvertSettings where we specify the name for input XLS, resultant format as pdf and the name for resultant PDF document as arguments.
var settings = new ConvertSettings{...}
  1. Call the ConvertDocumentRequest API to turn Excel to PDF and save the resultant PDF to the cloud storage.
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
excel to pdf

Image:- A preview of Excel to PDF conversion.

The sample Excel workbook and resultant PDF generated in the above example can be downloaded from input.xls and output.pdf.

Convert XLSX to PDF using cURL commands

Converting Excel to PDF using GroupDocs.Conversion Cloud and cURL commands offers a convenient and scriptable solution for users who prefer command-line interfaces or require batch conversion capabilities. With cURL commands, you can easily initiate the conversion process by specifying the input Excel file and setting the desired output format to PDF. Furthermore, this approach also simplifies the conversion process, by allowing you to seamlessly integrate document conversion capabilities into your scripts or automation pipelines.

Now, the first step in this approach is to obtain a personalized JWT access token. So, once you have a JWT token, please execute the following cURL command to convert XLSX to PDF format and save the resultant PDF in cloud storage.

curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{  \"StorageName\": \"internal\",  \"FilePath\": \"{sourceFile}\",  \"Format\": \"pdf\",  \"OutputPath\": \"{myOutput}\"}"

Please replace sourceFile with the name of input Excel workbook, myOutput with the name of resultant PDF and accessToken with personalized JWT access token.

  • In case we need to save the resultant PDF on local drive, please try using the following cURL command.
curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{  \"StorageName\": \"internal\",  \"FilePath\": \"input.xls\",  \"Format\": \"pdf\"}" \
-o "myOutput.pdf"

Free Excel to PDF Converter

In order to quickly test the capabilities of GroupDocs.Conversion Cloud SDK, please try using our free online XLSX to PDF Converter. It’s developed on top of GroupDocs.Conversion Cloud REST APIs. So while using this lightweight, super-efficient solution, you can witness the amazing capabilities of our Cloud SDK for Excel workbook to PDF conversion.

xlsx to PDF app


In conclusion, whether you choose to leverage GroupDocs.Conversion Cloud SDK for .NET or utilize cURL commands with GroupDocs.Conversion Cloud, converting Excel to PDF becomes a seamless and efficient process. Both approaches offer versatile solutions for automating document conversion tasks, providing flexibility and reliability. Therefore, we highly recommend exploring the capabilities of GroupDocs.Conversion Cloud SDK for .NET for a seamless and reliable solution for all document conversion needs.

We highly recommend visiting the following links to learn more about: