Images dissapear in excel documents when copying them with python

后端 未结 3 1936
南方客
南方客 2021-01-13 11:26
import openpyxl

def factuur():
    wb = openpyxl.load_workbook(\'factuurvoorbeeld1.xlsx\')
    Blad1 = wb.active
    Blad1[\'K7\'] = \'logo.png\'
    Blad1[\'E22\']         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-13 11:47

    Unfortunately openpyxl does not support images at this time, see official documentation: https://openpyxl.readthedocs.io/en/default/usage.html

    openpyxl does currently not read all possible items in an Excel file so images and charts will be lost from existing files if they are opened and saved with the same name.

    So when you open the template file, the images are not read, thus not saved in the new file.

    It might work if you insert the image again with openpyxl, by following the doc here: https://openpyxl.readthedocs.io/en/default/usage.html#inserting-an-image

提交回复
热议问题