From d0e37fc6760154317262800cf71da37579ca8e00 Mon Sep 17 00:00:00 2001 From: Gerry Date: Mon, 7 Jul 2025 18:01:03 +0800 Subject: [PATCH] Add annotation information for better use --- ...60\344\270\200\344\270\252sheet\344\270\255.py" | 14 ++++++++++++-- ...04\344\270\215\345\220\214sheet\344\270\255.py" | 13 ++++++++++++- ...27\357\274\214\346\213\206\345\210\206excel.py" | 12 +++++++++--- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git "a/examples/poexcel/\345\220\210\345\271\2662\344\270\252Excel\347\232\204\345\206\205\345\256\271\345\210\260\344\270\200\344\270\252sheet\344\270\255.py" "b/examples/poexcel/\345\220\210\345\271\2662\344\270\252Excel\347\232\204\345\206\205\345\256\271\345\210\260\344\270\200\344\270\252sheet\344\270\255.py" index f37f44e..2fb805b 100644 --- "a/examples/poexcel/\345\220\210\345\271\2662\344\270\252Excel\347\232\204\345\206\205\345\256\271\345\210\260\344\270\200\344\270\252sheet\344\270\255.py" +++ "b/examples/poexcel/\345\220\210\345\271\2662\344\270\252Excel\347\232\204\345\206\205\345\256\271\345\210\260\344\270\200\344\270\252sheet\344\270\255.py" @@ -1,6 +1,16 @@ # -*- coding: UTF-8 -*- +# 导入 poexcel 模块,该模块封装了对 Excel 文件的常用操作 import poexcel -poexcel.merge2sheet(dir_path=r'D:\workplace\code\github\python-office\tests\test_files\excel\merge2sheet', - output_sheet_name=r'platform', output_excel_name=r'./output/merge2sheet') +# 调用 poexcel 模块中的 merge2sheet 函数 +# 该函数的作用是将指定文件夹下的多个 Excel 文件合并到一个 Excel 文件的不同工作表中 +# 参数说明: +# - dir_path: 存放多个 Excel 文件的文件夹路径(原始字符串格式,避免转义问题) +# - output_sheet_name: 输出 Excel 中每个子表的命名规则或固定名称(例如根据文件名命名或统一命名) +# - output_excel_name: 合并后的输出 Excel 文件路径及文件名(原始字符串格式) +poexcel.merge2sheet( + dir_path=r'D:\workplace\code\github\python-office\tests\test_files\excel\merge2sheet', + output_sheet_name=r'platform', + output_excel_name=r'./output/merge2sheet' +) \ No newline at end of file diff --git "a/examples/poexcel/\345\220\210\345\271\266\345\244\232\344\270\252Excel\345\210\260\344\270\200\344\270\252Excel\347\232\204\344\270\215\345\220\214sheet\344\270\255.py" "b/examples/poexcel/\345\220\210\345\271\266\345\244\232\344\270\252Excel\345\210\260\344\270\200\344\270\252Excel\347\232\204\344\270\215\345\220\214sheet\344\270\255.py" index 59d4e1b..777bc08 100644 --- "a/examples/poexcel/\345\220\210\345\271\266\345\244\232\344\270\252Excel\345\210\260\344\270\200\344\270\252Excel\347\232\204\344\270\215\345\220\214sheet\344\270\255.py" +++ "b/examples/poexcel/\345\220\210\345\271\266\345\244\232\344\270\252Excel\345\210\260\344\270\200\344\270\252Excel\347\232\204\344\270\215\345\220\214sheet\344\270\255.py" @@ -1,5 +1,16 @@ # -*- coding: UTF-8 -*- +# 导入 office 模块,这是一个用于处理办公文档(如 Excel、Word、PPT)的 Python 工具库 import office -office.excel.merge2excel(dir_path=r'../../contributors/bulabean', output_file='test_merge2excel.xlsx', ) +# 调用 office 模块中的 excel 子模块下的 merge2excel 函数 +# 该函数的作用是将指定文件夹下的所有 Excel 文件(.xlsx / .xls)合并为一个 Excel 文件 +# 参数说明: +# - dir_path: 存放多个 Excel 文件的文件夹路径,支持相对路径或绝对路径 +# 此处使用的是相对路径 '../../contributors/bulabean' +# - output_file: 合并后输出的 Excel 文件名(字符串),例如 'test_merge2excel.xlsx' +# 输出路径默认为当前脚本所在目录,除非指定完整路径 +office.excel.merge2excel( + dir_path=r'../../contributors/bulabean', + output_file='test_merge2excel.xlsx' +) \ No newline at end of file diff --git "a/examples/poexcel/\346\240\271\346\215\256\346\214\207\345\256\232\347\232\204\345\210\227\357\274\214\346\213\206\345\210\206excel.py" "b/examples/poexcel/\346\240\271\346\215\256\346\214\207\345\256\232\347\232\204\345\210\227\357\274\214\346\213\206\345\210\206excel.py" index 1b6da6c..96761b6 100644 --- "a/examples/poexcel/\346\240\271\346\215\256\346\214\207\345\256\232\347\232\204\345\210\227\357\274\214\346\213\206\345\210\206excel.py" +++ "b/examples/poexcel/\346\240\271\346\215\256\346\214\207\345\256\232\347\232\204\345\210\227\357\274\214\346\213\206\345\210\206excel.py" @@ -1,10 +1,16 @@ # -*- coding: UTF-8 -*- - +# 导入处理 Excel 的模块(poexcel 是一个用于操作 Excel 的 Python 工具库) import poexcel +# 调用 poexcel 模块中的函数:split_excel_by_column +# 该函数的作用是根据指定列的值,将一个 Excel 文件拆分成多个子文件 +# 参数说明: +# - filepath: 待拆分的原始 Excel 文件路径(必须为字符串,使用原始字符串 r'' 避免转义问题) +# - column: 根据哪一列进行拆分(索引从 0 开始,column=1 表示第二列) +# - worksheet_name: 指定要操作的工作表名称,默认为所有工作表,若指定则只处理该工作表 poexcel.split_excel_by_column( filepath=r'D:\workplace\code\github\python-office\demo\poexcel\excel\split_excel_by_column.xlsx', column=1, - worksheet_name='platform') - + worksheet_name='platform' +) \ No newline at end of file