python给ppt表格加边框_向ppt里插入图片和表格

# 导入库

from pptx import Presentation

from pptx.util import Inches

ppt = Presentation() #新建幻灯片

slide = ppt.slides.add_slide(ppt.slide_layouts[1]) #插入新的幻灯片页面

'''Picture'''

# 指定图片的左右边距和高、宽

# left = Inches(1)

# top = Inches(1)

# width = Inches(2)

# height = Inches(2)

# 插入图片

# pic = slide.shapes.add_picture(C:\Users\13375\Desktop\pythonxiaohuangya.jpg',left,top,width,height)

# ppt.save(r'C:\Users\13375\Desktop\python\pptcharutupian.pptx')

'''表格的行列位置'''

rows = 4

cols = 4

left = Inches(3)

top = Inches(3)

width = Inches(6)

height = Inches(4)

table = slide.shapes.add_table(rows,cols,left,top,width,height).table #插入表格

table.columns[0].width = Inches(1) #设置第一列的宽度为1英寸

table.columns[1].width = Inches(3) # 设置第二列的宽度为3英寸

# 向表格里写入文字

table.cell(0,0).text = '1' #指定位置写入文本

table.cell(0,1).text = '2'

table.cell(1,0).text = '3'

table.cell(1,1).text = '4'

ppt.save(r'C:\Users\13375\Desktop\python\tables.pptx')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值