Excel to PDF

Convert XLSB to PDF | Develop Excel to PDF converter online

XLSB format specifies the Excel Binary File Format and is quite popular because it can be read from and written much faster, making it extremely useful for very large spreadsheets. However, in order to view the XLSB file, you need to use Microsoft Excel or OpenOffice Calc (multiplatform). But the conversion of these files to PDF is a viable solution. So in this article, we are going to discuss the details of how we can programmatically convert XLSB to PDF format.

Excel Conversion API

Aspose.Cells Cloud is a REST architecture-based Excel file processing API providing the capabilities to create, edit and transform to supported file formats. We are going to use Aspose.Cells Cloud SDK for .NET, so the first step is to install it over the system. Please visit the following article to learn more about how to install Aspose.Cloud SDKs.

XLSB to PDF in C#

Please follow the steps given below to perform XLSB to PDF conversion using C# .NET.

Convert Excel to PDF

In this section, we are going to discuss the steps for converting the complete workbook to PDF format.

  • First of all, create an instance of CellsApi class while passing ClientID and ClientSecret details as arguments
  • Secondly, read the input XLSB file into stream object using File.OpenRead
  • Thirdly, upload the XLSB file to cloud storage using UploadFile(…) method of CellsApi class
  • Finally, call the CellsWorkbookGetWorkbook(..) method taking input XLSB name, ouptut format details and name of resultant PDF file

Save Selected Worksheet to PDF

In this section, we are going to discuss the conversion of a specific worksheet in XLSB workbook to PDF format.

  • The first step is to create an instance of CellsApi class while passing ClientID and ClientSecret details as arguments
  • Secondly, read the input XLSB file into stream object using File.OpenRead
  • Now upload the XLSB file to cloud storage using UploadFile(…) method of CellsApi class
  • Finally, call the CellsWorksheetsGetWorksheet(..) method which takes input XLSB name, worksheet name to be converted and resultant output file name as arguments
Excel to PDF preview

Image 1:- Preview of Excel to PDF conversion

The sample files used in the above example can be downloaded from the input.xlsb, completeWorkbook.pdf, and Worksheet2.pdf.

Save Excel as PDF using cURL Command

The cURL commands are also among the easiest ways of accessing REST APIs, so we are going to follow two approaches for converting the XLSB file to PDF i.e. Converting the complete XLSB file to PDF format or converting a specific worksheet to PDF format. So first we need to generate JWT access token-based client credentials specified over Aspose.Cloud dashboard. For further details, please visit how to Obtain JWT token using a Client ID and Client Secret key.

Conversion of Complete Excel to PDF

Please use the following command to render the complete XLSB file already available in Cloud storage to PDF format and save the output to cloud storage.

curl -X GET "https://api.aspose.cloud/v3.0/cells/TestCase.xlsb?format=PDF&isAutoFit=true&onlySaveTable=false&outPath=Resultant.pdf" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

In case you need to save the output in the local drive, skip the outPath parameter value and use the -o parameter in the cURL command.

curl -X GET "https://api.aspose.cloud/v3.0/cells/TestCase.xlsb?format=PDF&isAutoFit=true&onlySaveTable=false" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-o localSave.pdf

Convert XLSB in Request to PDF

In case you need to convert an XLSB file to be uploaded from a local drive and perform the conversion. For this purpose, we need to use PutConvertWorkBook API. In this scenario, the XLSB will not be uploaded to Cloud storage but if the value is provided against the outPath parameter, the resultant file is saved on Cloud storage.

curl -X PUT "https://api.aspose.cloud/v3.0/cells/convert?format=PDF&outPath=putConvert.pdf" \
-H  "accept: multipart/form-data" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: multipart/form-data" \
-d @TestCase.xlsb

In case we need to load the XLSB from the local drive and perform the conversion to PDF and also, want to save the output on the local drive, then skip the value for outPath parameter and use -o argument in the cURL command.

curl -X PUT "https://api.aspose.cloud/v3.0/cells/convert?format=PDF" \
-H  "accept: multipart/form-data" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: multipart/form-data" \
-d @TestCase.xlsb \
-o conveted.pdf

Save Selected Worksheets of Excel to PDF

In case we need to only convert selected worksheets to PDF format, please try using GetWorkSheetWithFormat API. When executing the following command, Worksheet2 will be converted to PDF only.

curl -X GET "https://api.aspose.cloud/v3.0/cells/input.xlsb/worksheets/Sheet2?format=PDF&verticalResolution=0&horizontalResolution=0" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-o worksheet2.pdf

Conclusion

In this article, we have explored the steps regarding the conversion of the XLSB files to PDF format. Please note that our SDKs are open source and are developed under an MIT license. The complete source code is available on GitHub. While using the API, if you encounter any issues or you have any further queries, please feel free to contact us through the free customer support forum.

We recommend visiting the following links to learn more about