Convert Excel to PDF Using Python
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,
Excel File click here
Below is the Implementation: