openpyxl will let you add images, and it’s a relatively straightforward process. You will need to install another library,
Pillow, however, to process the image with Python. So, inside your environment, go ahead and
pip install Pillow.
I’ve included an image in the resources (Supporting Material) for this course called
rp.png, which is just the Real Python logo. Feel free to use that or any image that you have available. To do this, I’m going to make a new file called
Okay. And what should feel pretty familiar now is you’re going to define a
workbook—that’s going to be
load_workbook(). And for this one, go ahead and use the
"hello_world.xlsx" spreadsheet. Then, say
sheet is the active sheet off of that. All right, so now you can say something like
logo = Image() and then pass in the filename. In this case, it’ll be
Become a Member to join the conversation.