V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 165 天前 · 1063 次点击
    这是一个创建于 165 天前的主题,其中的信息可能已经有所发展或是发生改变。
    最近要写 word 日报,里面要填好多数据,还有图表

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

    问题二、python-docx 中怎么插入图表?
    官方文档只有 add_picture, 没有 add_chart
    7 条回复    2023-11-16 15:20:56 +08:00
    hefish
        1
    hefish  
       165 天前
    你可以写好了模板用替换字符串来做嘛。
    Alias4ck
        2
    Alias4ck  
       164 天前
    luis330
        3
    luis330  
       164 天前
    写好模板以后,我用 docxtpl 来读取数据和图表完成自动替换生成报告。
    https://pypi.org/project/docxtpl/
    solopython
        4
    solopython  
    OP
       164 天前
    @luis330 #3 这个是插入图片,不是图表吧
    solopython
        5
    solopython  
    OP
       164 天前
    @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  
       164 天前
    @solopython 兄弟你看没看呀 这个 feature 没合并哈哈 你可以参考它写的你本地加一下 他是参考 python-pptx 的
    luis330
        7
    luis330  
       163 天前
    @solopython #4 图片没问题,我用 [图表] 可能不准确。 此外他支持表格,对于不复杂的表格,是可以做好模板表格,直接用它填充数据进去。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   881 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 20:34 · PVG 04:34 · LAX 13:34 · JFK 16:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.