首页 文章

使用xlwings在Excel中插入图像

提问于
浏览
1

我尝试使用以下命令在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的文档?

1 回答

  • 3

    现在已经发布了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 .

相关问题