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