---
name: Split Excel by Column
slug: split-excel-by-column
category: Automation
description: Splits an Excel file into multiple files based on the contents of a specified column, creating one file per unique value. Use when you need to split Excel data by a column field.
github: "https://github.com/CoderWanFeng/python-office/tree/develop/skills/excel/split_excel_by_column"
language: Python
stars: 1331
forks: 297
install: "git clone https://github.com/CoderWanFeng/python-office"
added: 2026-07-20T06:48:41.993Z
last_synced: 2026-07-28T07:00:49.389Z
canonical_url: "https://dirskills.com/skills/split-excel-by-column"
---

# Split Excel by Column

Splits an Excel file into multiple files based on the contents of a specified column, creating one file per unique value. Use when you need to split Excel data by a column field.

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

## README

# split_excel_by_column Skill

> 按指定列的内容拆分 Excel 文件

## 功能描述

根据指定列的内容，将一个 Excel 文件拆分为多个 Excel 文件，每个唯一值对应一个新文件。

## 所属分类

`office/skills/excel/split_excel_by_column/`

## 调用方式

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

split_excel_by_column(
    filepath='./data.xlsx',
    column=0,
    worksheet_name=None
)
```

## 参数说明

| 参数 | 类型 | 必填 | 默认值 | 说明 |
|------|------|------|--------|------|
| `filepath` | str | 是 | - | 需要拆分的 Excel 文件路径 |
| `column` | int | 是 | - | 按哪一列的内容进行拆分（列索引） |
| `worksheet_name` | str | 否 | `None` | 指定工作表名称。默认处理第一个工作表 |

## 返回值

`None`

## 使用示例

```python
from office.skills.excel import split_excel_by_column
# 按第 0 列拆分
split_excel_by_column(filepath='./orders.xlsx', column=0)
```

## 原始函数

`office.api.excel.split_excel_by_column`
