Skip to content
Related Articles

Related Articles

Convert Excel to PDF Using Python

Improve Article
Save Article
  • Last Updated : 24 Feb, 2021
Improve Article
Save Article

Python is a high-level, general-purpose, and very popular programming language. Python programming language (latest Python 3) is being used in web development, Machine Learning applications, along with all cutting-edge technology in Software Industry.

In this article, we will learn how to convert an Excel File to PDF File Using Python

Here we will use the win32com module for file conversion.

What is win32com?

Python extensions for Microsoft Windows Provide access to much of the Win32 API, the ability to create and use COM objects, and the Pythonwin environment.

pip install pywin32


  • First, we will create a COM Object Using Dispatch() method.
  • Then we will read the Excel file pass “Excel.Application” inside the Dispatch method
  • Pass Excel file path
  • Then we will convert it into PDF using the ExportAsFixedFormat() method

ExportAsFixedFormat():- The ExportAsFixedFormat method is used to publish a workbook in either PDF or XPS format.


ExportAsFixedFormat (Type, FileName, Quality, IncludeDocProperties, IgnorePrintAreas, From, To, 

OpenAfterPublish, FixedFormatExtClassPtr)

Excel File click here



Below is the Implementation:


# Import Module
from win32com import client
# Open Microsoft Excel
excel = client.Dispatch("Excel.Application")
# Read Excel File
sheets = excel.Workbooks.Open('Excel File Path')
work_sheets = sheets.Worksheets[0]
# Convert into PDF File
work_sheets.ExportAsFixedFormat(0, 'PDF File Path')



My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!