Excel to PDF Python

Nowadays, PDF has become a standard file format for exchanging documents. Various popular document formats are converted to PDF before they are shared over the Internet. Excel to PDF is one of the popular conversion scenarios in which worksheets are converted to read-only PDF pages. In accordance with that, this article covers how to convert Excel XLSX or XLS files to PDF using Python.

Python Excel to PDF Converter API

For Excel to PDF conversion, we’ll use Aspose.Cells for Python API. It is a powerful spreadsheet manipulation API that lets you create, process, and convert Excel files from within your Python applications. You can install the API using the following pip command.

pip install aspose-cells

How Convert Excel to PDF in Python

The conversion of Excel files to PDF is as simple as pie using Aspose.Cells for Python. The following steps are required to save an Excel file in PDF format.

  • Load the Excel file from desired location.
  • Save it as PDF to the desired location.

And that’s it. Let’s have a look at how to transform these steps into code and convert an Excel XLS/XLSX file to PDF in Python.

Convert Excel XLSX to PDF in Python

The following are the steps to convert an Excel XLSX file to PDF using Python.

The following code sample shows how to convert an Excel XSLX file to PDF.

Excel File

Excel to PDF

Converted PDF

Converted PDF

Python XLSX XLS to PDF - Advanced Conversion

Aspose.Cells for Python also allows you to customize the XLSX to PDF conversion using different options. For example, you can set PDF compliance, compression, gridlines style, number of pages per sheet, etc. for the converted PDF file. The PdfSaveOptions class is used to set these options.

The following are the steps to use advanced options in XLSX to PDF conversion in Python.

The following code sample shows how to use advanced options in Excel XLSX to PDF conversion.

Python Excel to PDF Converter - Get a Free License

You can request a temporary license in order to use the API without evaluation limitations.

Conclusion

In this article, you have learned how to convert Excel XLSX or XLS to PDF in Python. Furthermore, the advanced options to control the Python Excel to PDF conversion are also discussed with the help of the code sample. You can explore more about Aspose.Cells for Python via Java using the documentation. In case you would have any queries, contact us via our forum.

See Also

Info: Aspose developed a free online web app that allows you to view PDFs online, another that allows you to convert PDFs to video, and one that allows you to edit PDFs online.