---
name: Excel to PDF
slug: excel-to-pdf
category: Automation
description: Converts a specified worksheet from an Excel file to a PDF file. Use when you need to export Excel data as a PDF document.
github: "https://github.com/CoderWanFeng/python-office/tree/develop/skills/excel/excel2pdf"
language: Python
stars: 1331
forks: 297
install: "git clone https://github.com/CoderWanFeng/python-office"
added: 2026-07-20T06:48:40.378Z
last_synced: 2026-07-28T07:00:48.382Z
canonical_url: "https://dirskills.com/skills/excel-to-pdf"
---

# Excel to PDF

Converts a specified worksheet from an Excel file to a PDF file. Use when you need to export Excel data as a PDF document.

**Install:** `git clone https://github.com/CoderWanFeng/python-office`

## README

# excel2pdf Skill

> 将 Excel 文件的指定工作表转换为 PDF 格式

## 功能描述

将 Excel 文件的指定工作表转换为 PDF 文件。

## 所属分类

`office/skills/excel/excel2pdf/`

## 调用方式

```python
from office.skills.excel import excel2pdf

excel2pdf(
    excel_path='./data.xlsx',
    pdf_path='./data.pdf',
    sheet_id=0
)
```

## 参数说明

| 参数 | 类型 | 必填 | 默认值 | 说明 |
|------|------|------|--------|------|
| `excel_path` | str | 是 | - | Excel 文件的路径 |
| `pdf_path` | str | 是 | - | 转换后生成的 PDF 文件的路径 |
| `sheet_id` | int | 否 | `0` | 工作表的索引（默认第一个工作表） |

## 返回值

`None`

## 使用示例

```python
from office.skills.excel import excel2pdf
excel2pdf(excel_path='./report.xlsx', pdf_path='./report.pdf', sheet_id=0)
```

## 视频教程

https://www.bilibili.com/video/BV1A84y1N7or/

## 原始函数

`office.api.excel.excel2pdf`
