Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 15581

Adding multiple instances of an image into xlsx using openpyxl

$
0
0

I have a task to automate the generation of reports in Excel. One of the features of this report is that it is necessary to add pictures of products, the same ones several times on different sheets. When the manager made this report manually, they just copied the pictures from sheet to sheet and the size of the report was not very large. When I started to automate this report in python + openpyxl, I faced the problem that I can't add the same picture twice - if I try to save this xlsx file, an error pops up:ValueError: I/O operation on closed file.I got around this problem by reopening the image file each time, but this led to the problem that the xlsx file now has many instances of the same image, which bloats the file size.

Is it possible to add the same picture to different sheets via openpyxl without creating copies and bloating the size of the final file?


Viewing all articles
Browse latest Browse all 15581

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>