使用Python中的xltpl模塊填充excel表格模板文件


相關鏈接: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的參數的形式。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM