Skip to content
Automation
Skill

/excel2json

把 Excel 工作表转换成 JSON,支持 records、columns、values 三种结构,日期自动转 ISO 字符串。当用户提到 Excel 转 JSON、表格转接口数据、Excel 生成 mock 数据时使用。

From plugin
python-office
1.4k80 skills

Claude Code

$ npx -y skills add coderwanfeng/python-office --skill excel2json --agent claude-code

SKILL.md

excel2json.SKILL.md
name: excel2json
description: 把 Excel 工作表转换成 JSON,支持 records、columns、values 三种结构,日期自动转 ISO 字符串。当用户提到 Excel 转 JSON、表格转接口数据、Excel 生成 mock 数据时使用。

excel2json Skill

> 把 Excel 转成程序能直接消费的 JSON

功能描述

把工作表转换成 JSON 兼容的 Python 对象,可直接写入文件或当接口数据使用。 三种结构:`records`(每行一个对象)、`columns`(每列一个数组)、`values`(纯二维数组)。 空单元格转 `null`,日期时间转 ISO 字符串,重复的列名自动加 `_2`、`_3` 后缀避免覆盖。

所属分类

`skills/excel/excel2json/`

调用方式

from skills.excel import excel2json

data = excel2json('商品表.xlsx', orient='records', output_path='goods.json')

参数说明

| 参数 | 类型 | 必填 | 默认值 | 说明 | |------|------|------|--------|------| | `excel_path` | str | 是 | - | Excel 文件路径 | | `sheet_name` | str | 否 | `None` | 工作表名,默认取第一个 | | `orient` | str | 否 | `'records'` | `records`、`columns` 或 `values` | | `output_path` | str | 否 | `None` | JSON 输出路径,指定后同时写文件 | | `indent` | int | 否 | `2` | 写文件时的缩进,`None` 表示压缩 | | `ensure_ascii` | bool | 否 | `False` | 是否把中文转成 `\uXXXX` |

返回值

`list | dict`:`records` 和 `values` 返回列表,`columns` 返回字典。

使用示例

from skills.excel import excel2json

rows = excel2json('商品表.xlsx')
print(rows[0])            # {'商品名': '苹果', '价格': 5.5}

by_column = excel2json('商品表.xlsx', orient='columns')
print(by_column['价格'])   # [5.5, 3.0, ...]

excel2json('商品表.xlsx', output_path='goods.json', ensure_ascii=False)

原始函数

`contributors/my12yyds/excel2json.py`

@coderwanfeng
Ships withpython-office

pip install python-office 自动化办公专用库

Stars on GitHub

Momentum

stars in total
1.4k
Star history of coderwanfeng/python-office on GitHub, a chart by star-history.com

Other skills on python-office.

excel2csv
Skill

excel2csv

把 Excel 工作表导出为 CSV,默认 utf-8-sig 编码解决中文乱码,支持多工作表批量导出。当用户提到 Excel 转 CSV、表格转文本、CSV 乱码时使用。

excel_dedupe
Skill

excel_dedupe

按指定列或整行给 Excel 去重,返回重复行与保留行的对应关系,可导出干净数据。当用户提到 Excel 去重、删除重复项、重复数据、查重时使用。

excel_diff
Skill

excel_diff

比对两份 Excel 表格的差异,按位置或按主键找出修改、新增、删除的行,可导出差异表。当用户提到对比 Excel、Excel 差异、两份表格有什么不同、核对表格时使用。

More skills from other plugins.

agent-builder
Skill

agent-builder

Load immediately after an Agent intent, before the first agent_builder_* call. Governs how you create, configure, test, and…

n8n3d209k
@n8n-io@n8n-ioInstall Skill

Questions about excel2json.

Which coding agents can use excel2json?
excel2json installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.