How to convert Excel to PDF using Python
Table of contents
Convert Excel to PDF using Nutrient’s Python API. Create a free account, get API credentials, and implement conversion using the requests library. Combine with 30+ other API tools for merging, watermarking, and page manipulation.
Convert Excel files to PDFs using Nutrient DWS Processor’s XLSX-to-PDF Python API. The free plan includes 200 credits. Different operations consume different amounts of credits. Create a free account(opens in a new tab) to get your API key.
Why convert Excel to PDF?
Converting Excel files to PDF is essential for workflows requiring document standardization and sharing. Common use cases include:
- Document preservation — Convert spreadsheets to PDFs to preserve formatting, formulas, and layouts regardless of software or device used to view them.
- Professional reporting — Generate polished financial reports, invoices, and data summaries that maintain consistent appearance across platforms.
- Compliance and archiving — Create tamper-resistant records for auditing, regulatory compliance, and long-term document storage.
- Universal sharing — Share data with stakeholders who don’t have Excel or prefer read-only formats that prevent accidental editing.
- Print-ready documents — Ensure spreadsheets print exactly as intended without pagination or formatting issues.
The Excel-to-PDF API automates this process in your workflow.
Nutrient DWS Processor API
Converting Excel-to-PDF is one of 30+ operations available through our PDF API tools. Combine Excel-to-PDF conversion with other tools for complex workflows:
- Converting various file formats and consolidating them into PDFs
- Converting Excel files and then watermarking and flattening the PDFs
- Processing multiple Excel files before merging them into a single PDF
Your account includes access to all PDF API tools.
Step 1 — Creating a free account on Nutrient DWS Processor
Go to the signup page(opens in a new tab) to create your free account.

After account creation, the dashboard shows your plan details.
You start with 200 credits and access to all PDF API tools.
Step 2 — Obtaining the API key
After email verification, get your API key from the dashboard. Click API keys in the left menu to see your keys.

Copy the Live API key for the Excel-to-PDF API.
Step 3 — Setting up folders and files
Create a folder called excel_to_pdf and open it in a code editor. This tutorial uses VS Code. Create two folders inside excel_to_pdf: input_documents and processed_documents.
Copy your Excel file to the input_documents folder and rename it to document.xlsx. Use the demo document if needed.
In the root folder, excel_to_pdf, create a file called processor.py for your code.
Your folder structure will look like this:
excel_to_pdf├── input_documents| └── document.xlsx├── processed_documents└── processor.pyStep 4 — Writing the code
Open the processor.py file and paste the code below into it:
import requestsimport json
response = requests.request( 'POST', 'https://api.nutrient.io/build', headers = { 'Authorization': 'Bearer YOUR_API_KEY_HERE' }, files = { 'file': open('input_documents/document.xlsx', 'rb') }, data = { 'instructions': json.dumps({ 'parts': [ { 'file': 'file' } ] }) }, stream = True)
if response.ok: with open('processed_documents/result.pdf', 'wb') as fd: for chunk in response.iter_content(chunk_size=8096): fd.write(chunk)else: print(response.text) exit()Make sure to replace YOUR_API_KEY_HERE with your API key.
Code explanation
The code imports the requests and json dependencies, and then creates the instructions for the API call.
Use the requests module to make the API call. Once it succeeds, the result is saved to the processed_documents folder.
Output
Run the code:
python3 processor.pyAfter execution, you’ll find result.pdf in the processed_documents folder.
The folder structure will look like this:
excel_to_pdf├── input_documents| └── document.xlsx├── processed_documents| └── result.pdf└── processor.pyAdditional resources
Explore more ways to work with Nutrient API:
- Postman collection — Test API endpoints directly in Postman
- Zapier integration — Automate document workflows without code
- MCP Server — PDF automation for LLM applications
- Python client — Official Python library for Nutrient API
Conclusion
This post covered converting Excel files to PDF documents using the Python API.
Integrate these functions into your existing applications. The same API token works for other operations like merging documents, adding watermarks, and more. Sign up(opens in a new tab) for a free trial.
FAQ
No. Start with a free account that provides 200 credits for processing documents. Different operations consume different amounts of credits, so you can process varying numbers of documents depending on the operations you use.
Yes. Nutrient DWS Processor API maintains spreadsheet formatting, including fonts, colors, cell borders, and merged cells. Complex formulas are calculated and displayed as values in the PDF output.
Yes. The Nutrient Python client provides a higher-level interface for Nutrient DWS Processor API operations. While this tutorial uses direct HTTP requests with the requests library for transparency, the Python client simplifies authentication, error handling, and response parsing for production applications.
Yes. Nutrient DWS Processor API converts all sheets in an Excel workbook to a single PDF document, with each sheet appearing as a separate page or set of pages depending on the sheet size.