使用openpyxl在Excel表格中插入图片

发布于 2023-04-24  231 次阅读


Please refresh the page if equations are not rendered correctly.
---------------------------------------------------------------

代码

from openpyxl import Workbook
from openpyxl.drawing.image import Image

wb=Workbook()
ws=wb.active
ws["A1"]="You should see three logos below"

img = Image('logo.png')
ws.add_image(img, 'A2')
wb.save('logo.xlsx')

图片资源

将下面的图片另存为logo.png用于代码测试:

届ける言葉を今は育ててる
最后更新于 2023-04-24