Openpyxl Adding Image

  • Images aren't generally used in a spreadsheet but sometimes we will use as per our requirement.
  • we will use an image for the branding purposes or to form the spreadsheet more personal and attractive.
  • For adding an image to spreadsheet, we'd like to install a further module called pillow by the following command.
    • pip install pillow
 Openpyxl Adding Image

Openpyxl Adding Image

Sample Code

from openpyxl import load_workbook
from openpyxl.drawing.image import Image  

# Let's use the hello_world spreadsheet since it has less data  
workbook = load_workbook(filename="merging.xlsx")  
sheet =

logo = Image(r"logo.png")  

# A bit of resizing to not fill the whole spreadsheet with the logo  
logo.height = 150  
logo.width = 300  

sheet.add_image(logo, "E2")"logo.xlsx")


Related Searches to Openpyxl Adding Image

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add to your ad blocking whitelist or disable your adblocking software.