gpt4 book ai didi

python - 使用 xlwings 在 Excel 中插入图像

转载 作者:行者123 更新时间:2023-11-30 23:05:17 29 4
gpt4 key购买 nike

我尝试使用 Mac 上的 xlwings/appscript 使用以下命令将图像插入到 Excel 中:

 Sheet('sheet1').xl_sheet.shapes.pictures.open('test.png')

但结果是打开带有图像代码的 Excel 工作簿。我尝试了很多扩展,但没有找到正确的扩展。

 xl_sheet.shapes.pictures.width
xl_sheet.shapes.pictures.height
xl_sheet.shapes.pictures.drop

有人知道如何处理它以及是否存在 AppleScript 和 Python 的文档吗?

最佳答案

现已与 xlwings v0.5.0 一起发布:

示例:

import xlwings as xw
pic = xw.Picture(1, 'picture_name') # To manipulate an existing picture
pic = xw.Picture.add('path/to/picture.jpg', sheet=1) # add a new one

请参阅docs了解详情。

关于python - 使用 xlwings 在 Excel 中插入图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33222713/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com