推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
solopython
V2EX  ›  Python

有熟悉 Python -docx 的大佬吗?

  •  
  •   solopython · Nov 14, 2023 · 2106 views
    This topic created in 937 days ago, the information mentioned may be changed or developed.
    最近要写 word 日报,里面要填好多数据,还有图表

    问题一、python-docx 怎么添加中文列表?
    例如:
    一、xxx
    二、yyy
    三、zzz
    或者
    (一) aaa
    (二) bbb
    (三) ccc
    官方文档只有 List Number 和 List Bullet

    问题二、python-docx 中怎么插入图表?
    官方文档只有 add_picture, 没有 add_chart
    7 replies    2023-11-16 15:20:56 +08:00
    hefish
        1
    hefish  
       Nov 14, 2023
    你可以写好了模板用替换字符串来做嘛。
    Alias4ck
        2
    Alias4ck  
       Nov 15, 2023
    luis330
        3
    luis330  
       Nov 15, 2023
    写好模板以后,我用 docxtpl 来读取数据和图表完成自动替换生成报告。
    https://pypi.org/project/docxtpl/
    solopython
        4
    solopython  
    OP
       Nov 15, 2023
    @luis330 #3 这个是插入图片,不是图表吧
    solopython
        5
    solopython  
    OP
       Nov 15, 2023
    @Alias4ck #2 试了不行
    Python 3.6.8 , python-docx 0.8.10, python-pptx 0.6.18
    报错 AttributeError: 'Document' object has no attribute 'add_chart'
    Alias4ck
        6
    Alias4ck  
       Nov 15, 2023
    @solopython 兄弟你看没看呀 这个 feature 没合并哈哈 你可以参考它写的你本地加一下 他是参考 python-pptx 的
    luis330
        7
    luis330  
       Nov 16, 2023
    @solopython #4 图片没问题,我用 [图表] 可能不准确。 此外他支持表格,对于不复杂的表格,是可以做好模板表格,直接用它填充数据进去。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1022 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 22:34 · PVG 06:34 · LAX 15:34 · JFK 18:34
    ♥ Do have faith in what you're doing.