IRONSOFTWAREHOME
Add, Extract, and Remove Images in Excel with C#
using IronXL;
using IronSoftware.Drawing;
using System.Collections.Generic;

WorkBook workBook = WorkBook.Create();
WorkSheet workSheet = workBook.DefaultWorkSheet;

// Insert images
workSheet.InsertImage("ironpdf.jpg", 2, 2, 4, 4);
workSheet.InsertImage("ironpdfIcon.png", 2, 6, 4, 8);

// Retreive images
List<IronXL.Drawing.Images.IImage> images = workSheet.Images;
// Select each image
foreach (IronXL.Drawing.Images.IImage image in images)
{
    // Save the image
    AnyBitmap anyBitmap = image.ToAnyBitmap();
    anyBitmap.SaveAs($"{image.Id}.png");
}

// Remove image
workSheet.RemoveImage(3);

workBook.SaveAs("images.xlsx");
Imports IronXL
Imports IronSoftware.Drawing

Dim workBook As WorkBook = WorkBook.Create()
Dim workSheet As WorkSheet = workBook.DefaultWorkSheet

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

' Retreive images
Dim images As List(Of IronXL.Drawing.Images.IImage) = workSheet.Images
' Select each image
For Each image As IronXL.Drawing.Images.IImage In images
    ' Save the image
    Dim anyBitmap As AnyBitmap = image.ToAnyBitmap()
    anyBitmap.SaveAs($"{image.Id}.png")
Next

' Remove image
workSheet.RemoveImage(3)

workBook.SaveAs("images.xlsx")
NuGet Download
PM > Install-Package IronXL.Excel
Add, Extract, and Remove Images in Excel with C#

Add, Extract, and Remove Images in Excel with C#

Add Images Example

To insert an image into a spreadsheet, use the InsertImage method. It supports various image types, such as JPG/JPEG, BMP, PNG, GIF, and TIFF. You need to specify the top-left and bottom-right corners of the image in the Worksheet to determine its dimensions. The dimensions 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 provides a list of all the images contained within the sheet. From this list, you can perform various operations, such as exporting, resizing, retrieving positions, and obtaining the byte data of each image. Notably, the image IDs follow an odd-numbered pattern, incrementing in the sequence of 1, 3, 5, 7, and so on.

Remove Image Example

Following the extract images example, you can easily remove any inserted image using its corresponding index number. Simply pass the image's ID number to the RemoveImage method to remove it from the Worksheet.

Explore How to Manipulate Excel Images with IronXL
View on GitHub

Ready to Get Started?

Nuget Downloads 2,237,574Version: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