docxtpl - 向表格里插入图片
以写文件的形式将图片插入,循环变量,循环插入图片
# -*- coding: utf-8 -*-
'''
Created : 2017-01-14@author: Eric Lapouyade
'''from docxtpl import DocxTemplate, InlineImage# for height and width you have to use millimeters (Mm), inches or points(Pt) class :
from docx.shared import Mm
import jinja2tpl = DocxTemplate('templates\\inline_image_tpl.docx')context = {'myimage': InlineImage(tpl, 'templates\\python_logo.png', width=Mm(20)),'myimageratio': InlineImage(tpl, 'templates\\python_jpeg.jpg', width=Mm(30), height=Mm(60) ),'frameworks': [{'image': InlineImage(tpl, 'templates\\django.png', height=Mm(10)),'desc': 'The web framework for perfectionists with deadlines',},{'image': InlineImage(tpl, 'templates\\zope.png', height=Mm(10)),'desc': 'Zope is a leading Open Source Application Server and Content Management Framework',},{'image': InlineImage(tpl, 'templates\\pyramid.png', height=Mm(10)),'desc': 'Pyramid is a lightweight Python web framework aimed at taking small web apps into big web apps.',},{'image': InlineImage(tpl, 'templates\\bottle.png', height=Mm(10)),'desc': 'Bottle is a fast, simple and lightweight WSGI micro web-framework for Python',},{'image': InlineImage(tpl, 'templates\\tornado.png', height=Mm(10)),'desc': 'Tornado is a Python web framework and asynchronous networking library.',},],
}
# testing that it works also when autoescape has been forced to True
jinja_env = jinja2.Environment(autoescape=True)
tpl.render(context, jinja_env)
tpl.save('templates\\output\\inline_image.docx')
docxtpl - 向表格里插入图片相关推荐
- element-ui在表格里插入图片或者链接等
element-ui在表格里插入图片或者链接等 最近在项目中遇到一个要求,需要在表格里插入图片或者显示链接之类的,如果按照下面的方式写 <el-table-columnlabel="博 ...
- html 表格中图片显示不全,为何Word 向表格里插入图片时显示不全呢? 有图!
回答: 如果只显示边框的话,我的解决办法是工具-选项-视图,将图片框前的复选 去掉 以下为其他原因 ------------------------------------ 图片或对象的格式为&quo ...
- 为何Word 向表格里插入图片时显示不全呢?
原因是:这个word文档设定了固定的行距而导致的,上面的显示永远显示的一小半截其实就是一行的宽度. 1.选择图片,在开始界面,点击如图所示段落下面的小箭头. 2. 在弹出的段落格式对话框中,你会发现, ...
- python数据写入表格生成图片_python在word文档里插入图片和表格实例代码演示
# -*- coding: UTF8 -*- from docx import Document from docx.shared import Pt doc = Document() # 文件存储路 ...
- ecplise插入图片太大_【Excel里插入图片时很大怎么办?我想把他设置成自动适应表格的大小。】excel图片固定大小...
excel插入自适应单元格大小图片 excel入的图片可以设置自适应单元格大小而变化,具体操作如下: 一.使具:excel2010 二.操作步骤: 1.进入excel2010,点击"插入&q ...
- 怎么在html表格里加入图片不显示不出来,WPS表格里插入的嵌入式图片在Office的Excel无法正常显示...
WPS表格里插入的嵌入式图片 是=DISPIMG格式,这个图片是wps特有的功能,它不是shape, 有shapes集合中找不到.只能用wps的et表格打开才能看到这个图片 在Excel中打开会显示为 ...
- html背景图总是在字的下面,怎么我在excel表格里插入背景图片后图片不是显示在文字下面而跑到文字右边的...
怎么我在excel表格里插入背景图片后图片不是显示在文字下面而跑到文字右边的以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧 ...
- 测试用例------表格里面插入图片
表格分类:Excle表格,wps表格,Office表格 ... 功能 1.表格里能否插入图片 2.能否插入各种格式的图片 bmp,jpg,png,tif,gif,pcx,tga,exif,fpx,s ...
- word文档里插入图片显示不完整,只显示一半,怎么处理?
word文档里插入图片显示不完整,只显示一半,怎么处理? 目录 word文档里插入图片显示不完整,只显示一半,怎么处理? 1.把鼠标光标放置图片的末尾,然后点击鼠标右键,选择[段落]选项 2.在[缩进 ...
最新文章
- P1160 队列安排
- c语言实现椭圆曲线算法,椭圆曲线加密算法的C语言设计和实现
- classic example2
- 量化金融笔记1-股票量化基础
- dell进入u盘启动模式_戴尔主板bios设置u盘启动
- 服务器用户与组没有everyone,一招教你为Windows 7共享文件夹设置Everyone权限
- windows7最简单最快速解决“此windows副本不是正版”(“This copy of Windows is not genuine”)方法
- rails consol reload!
- flex横向纵向间距,自适应排列
- 华栖云与阿里云首推“云上电视台”,可实现内容云端一站式制作
- 时域采样与频域采样实验报告_光时域反射仪(OTDR)如何工作(光电读书)
- java jdk7,jdk8连接oracle19C数据库ojdbc驱动
- TDM音频各个时钟频率关系解析
- SwitchyOmega情景模式
- [英雄星球六月集训LeetCode解题日报] 第七日 哈希表
- 全球与中国汽车空气悬架系统市场现状及未来发展趋势
- Glide加载图片完成的回调
- 期货交易是否会导致孤僻,甚至忧郁?
- Delphi TStringGrid 类(1)
- python做多项式拟合并绘图