Excel spreadsheets are widely used for the creation of receipts, invoices, ledgers, inventory, accounts, and other reports. XLS or XLSX to PDF conversion API allows sharing Excel data with others in a portable form. As a Ruby developer, you can easily convert your Excel Spreadsheets to PDF documents programmatically on the cloud. In this article, we will learn how to convert Excel Spreadsheets to PDF using Ruby.
The following topics shall be covered in this article:
- Excel to PDF Conversion REST API and Ruby SDK
- Convert Excel to PDF using a REST API in Ruby
- Convert Specific Excel Spreadsheets to PDF in Ruby
- Excel to PDF Conversion in Ruby using Advanced Options
- Convert Excel to PDF and Add Watermark
- Online XLSX to PDF Converter for Free
Excel to PDF Conversion REST API and Ruby SDK
To convert XLSX to PDF, we will be using the Ruby SDK of GroupDocs.Conversion Cloud API. The API allows you to convert your documents to any format you need. Cloud API also support the conversion of more than 50 types of documents like Word, Excel, PowerPoint, PDF, HTML, JPG, PNG, CAD. REST API also provides .NET, Java, PHP, Node.js, Android, and Python SDKs as its document conversion family members for the Cloud EST API.
You can install GroupDocs.Conversion Cloud to your Ruby application using the following command in the console:
gem install groupdocs_conversion_cloud
Please get your Client ID and Client Secret from the dashboard before you start following the steps and available code examples. Once you have your ID and secret, add in the code as shown below:
Convert Excel to PDF using a REST API in Ruby
You can convert Excel Spreadsheets to PDF documents on the cloud by following the simple steps given below: You can easily convert XLSX to PDF document programmatically by following the steps mentioned below:
- Create an instance of the ConvertApi
- Create an instance of the ConvertSettings
- Set the XLSX file path
- Assign “pdf” to format
- Create an instance of the SpreadsheetLoadOptions
- Set hide_comments and one_page_per_sheet values
- Provide load_options and output file path
- Create ConvertDocumentRequest with ConvertSettings
- Convert by calling the ConvertApi.convertDocument() method with ConvertDocumentRequest
The following code example shows how to convert Excel Spreadsheet to a PDF document using a REST API in Ruby.
Convert Specific Excel Spreadsheets to PDF in Ruby
You can convert specific Excel Spreadsheets to PDF documents programmatically by following the steps mentioned below:
- Create an instance of the ConvertApi
- Create an instance of the ConvertSettings
- Set the XLSX file path
- Assign “pdf” to format
- Create an instance of PdfConvertOptions
- Provide specific Spreadsheets pages to convert
- Set PdfConvertOptions and provide output file path
- Create ConvertDocumentRequest with ConvertSettings
- Convert by calling the ConvertApi.convertDocument() method with ConvertDocumentRequest
The following code example shows how to convert a specific Excel Spreadsheet to a PDF document using a REST API in Ruby.
Excel to PDF Conversion in Ruby using Advanced Options
Please follow the steps mentioned below to convert XLSX to PDF document with some advanced settings:
- Create an instance of the ConvertApi
- Create an instance of the ConvertSettings
- Set the XLSX file path
- Assign “pdf” to format
- Create an instance of the SpreadsheetLoadOptions
- Set various load options such as hideComments, onePagePerSheet, etc.
- Create an instance of PdfConvertOptions
- Set different convert options to convertOptions
- Provide load_options, convertOptions and output file path
- Create ConvertDocumentRequest with ConvertSettings
- Convert by calling the ConvertApi.convertDocument() method with ConvertDocumentRequest
The following code example shows how to convert Excel Spreadsheet to a PDF document with advanced convert options:
Convert Excel to PDF and Add Watermark
You can convert Excel Spreadsheets to watermarked PDF documents by following the steps mentioned below:
- Create an instance of the ConvertApi
- Create an instance of the ConvertSettings
- Set the XLSX file path
- Assign “pdf” to format
- Create an instance of the WatermarkOptions
- Set Watermark Text, Color, Width, Height, etc.
- Define the PdfConvertOptions and assign WatermarkOptions
- Set convert options and output file path
- Create ConvertDocumentRequest with ConvertSettings
- Convert by calling the ConvertApi.convertDocument() method with ConvertDocumentRequest
The following code example shows how to convert Excel Spreadsheet to PDF document and add a watermark to the converted PDF document using a REST API in Ruby.
Online XLSX to PDF Converter for Free
How to convert Excel to PDF online? You can try the following free online XLSX to PDF converter tool, which is developed using the above API.
Conclusion
In this article, you learned how to convert Excel to PDF documents on the cloud. You also have learned how to add a watermark to the converted PDF document using Ruby. Additionally, we learned how to programmatically convert XLSX to PDF file on the cloud using advanced options. You can learn more about GroupDocs.Conversion Cloud API using the documentation. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser.
Ask a question
If you have any queries about XLSX to PDF Converter, please feel free to ask us on the Forum.