# Markdown
Markdown 自动化办公的实现,依赖的第三方库是:pomarkdown
源码地址:https://github.com/CoderWanFeng/pomarkdown
安装:
pip install pomarkdown
# 1、Excel 转 Markdown
将 Excel 表格转换为 Markdown 格式的表格,支持单个文件和批量转换。
单个文件转换:
import pomarkdown
pomarkdown.excel2markdown(
input_file=r'D:\data\报告.xlsx',
output_file=r'D:\data\报告.md'
)
转换指定工作表:
import pomarkdown
pomarkdown.excel2markdown(
input_file=r'D:\data\数据汇总.xlsx',
output_file=r'D:\data\销售数据.md',
sheet_name='Sheet1' # 指定要转换的工作表名称
)
批量转换(整个文件夹):
import pomarkdown
pomarkdown.excel2markdown(
input_path=r'D:\excel_files', # 存放 Excel 文件的文件夹
output_path=r'D:\markdown_files' # Markdown 输出目录
)
参数说明:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
input_file | str | 否 | 单个 Excel 文件路径(与 input_path 二选一) |
output_file | str | 否 | 单个 Markdown 输出文件路径(与 output_path 二选一) |
sheet_name | str | 否 | 指定工作表名称,不填则转换所有工作表 |
input_path | str | 否 | Excel 文件所在的文件夹路径(批量模式) |
output_path | str | 否 | Markdown 输出目录(批量模式) |
💡 使用
input_file/output_file处理单个文件,使用input_path/output_path批量处理整个文件夹。
