相關鏈接:https://pypi.org/project/xltpl/
from xltpl.writerx import BookWriter def fix_info_excel(): """填充xxx信息的excel表格""" writer = BookWriter('./xxx信息表.xlsx') ws_info_map = { "sheet_name": "xxxx提供表", "tpl_idx": 0, "client": "xxx科技", "td_no": "58888", "bug_description": "沒電了", "reason": "這是啥原因", "reappear_advise": "復現建議", "fix_notes": "改動說明", "test_advice": "測試建議", "git_path": "git地址", "is_warn": "否", "plan_to_finished_date": "2020-06-15", "add_user": "ldd" } sheet_info = { "xxx開發提供表": ws_info_map, "文件的MD5值": { "sheet_name": "文件的MD5值", "tpl_idx": 1, }, } writer.render_book(sheet_info) writer.save('xxxwww信息表.xlsx')
說明:這個Python庫的在模板表格中的單元格有批注的情況下,批注的樣式不會保留,同時如果有多個sheet,需要注意傳入sheet_info的參數的形式。