weixin_39922147 2020-11-29 13:09
浏览 0

Insert a picture only if it doesn't exist

How do I add (i.e insert) a picture file only if it doesn't exist? Currently I'm using:

 python
xw.Picture.add(fig_path + '/quality_index.png', sheet='Overall Index',
               left=xw.Range('G1').left, top=xw.Range('G1').top,
               height=400, width=500)

However every time I run my python script a new picture is inserted on top of the prexisiting one. I would like to check if that picture exists (by assigning it a name first?) and then only insert it if it doesn't exist.

Bonus: can I specify the size of the picture in cm or inches?

Thanks!!

该提问来源于开源项目:xlwings/xlwings

  • 写回答

6条回答 默认 最新

  • weixin_39922147 2020-11-29 13:09
    关注

    This is how it's being done for the matplotlib chart picture, you should be able to apply the same principle: https://github.com/ZoomerAnalytics/xlwings/blob/master/xlwings/main.py#L2014-L2020

    评论

报告相同问题?