IRONSOFTWAREHOME
Add, Extract & Remove Worksheet Images
from ironxl import *

# Create a new Excel workbook
workbook = WorkBook.Create()
worksheet = workbook.DefaultWorkSheet

# Insert images
worksheet.InsertImage("ironpdf.jpg", 2, 2, 4, 4)
worksheet.InsertImage("ironpdfIcon.png", 2, 6, 4, 8)

# Retrieve images
images = worksheet.Images

# Select each image
for i, image in enumerate(images):
    # Save the image
    any_bitmap = image.ToAnyBitmap()
    any_bitmap.SaveAs(f"{image.Id}.png")

# Remove image
worksheet.RemoveImage(3)

# Save changes with inserted and removed images
workbook.SaveAs("images.xlsx")
pip install ironxl
Add, Extract & Remove Worksheet Images

Add, Extract & Remove Worksheet Images

Add Images Example

To insert an image into a worksheet, use the InsertImage method. It supports various image types including JPG/JPEG, BMP, PNG, GIF, and TIFF. You specify the top-left and bottom-right corners of the image within the worksheet to determine its dimensions. The width and height are calculated by subtracting the start and end column and row indices.

Extract Images Example

To extract images from the selected worksheet, access the Images property, which returns a list of all images contained within the sheet. From this list, you can perform operations such as exporting, resizing, retrieving position data, and obtaining the raw byte data of each image. Note that image IDs follow an odd-numbered pattern, incrementing in the sequence 1, 3, 5, 7, and so on.

Remove Images Example

Following the extract images example, any inserted image can be removed using its corresponding ID number. Pass the image's ID to the RemoveImage method to delete it from the worksheet.

Explore How to Manipulate Excel Images with IronXL for Python

Ready to Get Started?

Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required