Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created April 2, 2021 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/aa32e346fae9721e49032e37600a339e to your computer and use it in GitHub Desktop.
Save aspose-com-gists/aa32e346fae9721e49032e37600a339e to your computer and use it in GitHub Desktop.
Convert Excel Files to PDF in Python
# Load Excel file
workbook = Workbook("Book1.xlsx")
# Create and set PDF options
pdfOptions = PdfSaveOptions()
pdfOptions.setCompliance(PdfCompliance.PDF_A_1_B)
# Convert Excel to PDF
workbook.save("xlsx-to-pdf.pdf", pdfOptions)
# Load Excel file
workbook = Workbook("Book1.xlsx")
# Convert Excel to PDF
workbook.save("xlsx-to-pdf.pdf", SaveFormat.PDF)
@AhmedHelalM
Copy link

what if i have around 40 excel files , and need to convert them to PDF , and add also head letter of company ?

@shubham244
Copy link

----> 1 workbook.save("xlsx-to-pdf.pdf", SaveFormat.PDF)

AttributeError: 'Workbook' object has no attribute 'save'

@amjad-sahi
Copy link

amjad-sahi commented Dec 3, 2021

@AhmedHelalM,

You can convert as many Excel files to PDF format as you like. To add header letter of the company, you may take company's header letter picture and add this image as header picture (via relevant PageSetup method) using Aspose.Cells APIs before rendering to PDF.

@shubham244,

The method is there, see the API reference page. Make sure you have installed latest Aspose.Cells for Python via Java version, e.g. using the following pip command.
pip install aspose-cells and then import/set relevant classes and other objects initialized at the start of your sample code accordingly:
e.g.

import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook, SaveFormat, PdfSaveOptions
........

We also recommend you to post your queries or issue in dedicated forums here.

@himanshithakkar13
Copy link

It leaves aspose mark on pdf? Can anyone help How to remove "Evaluation Only. Created with Aspose Cells for Python via Java.Copyright 2003 - 2023 Aspose pty Ltd." Please help anyone its urgent.

@amjad-sahi
Copy link

@himanshithakkar13,

If you are using Aspose.Cells for Python via Java API in evaluation (default) mode, an evaluation watermark will appear in the output file. To remove the watermark, you need to have a valid license and set it in code (at the start) before using any other API of Aspose.Cells for Python via Java. For more information on licensing, please refer to the document on licensing. If you want to test the API without any limits, you may request a 30-day temporary license. Please refer to How to get a Temporary License? for more information. If you have any queries or comments, please post them in the dedicated forum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment