IRONSOFTWAREHOME

How to Add, Extract, and Remove Images in Excel Using C#

Curtis Chau
Curtis Chau
Updated: August 2, 2026

IronXL enables C# developers to programmatically insert images into Excel worksheets, extract existing images with their properties, and remove unwanted images using simple API methods without Excel Interop dependencies. This functionality is essential when creating Excel files in .NET that require visual elements like company logos, product images, or data visualization graphics.

Adding images enriches data with relevant graphics or illustrations. Removing images simplifies content editing and organization. Extracting images allows repurposing them in other documents or applications and updating existing images. These features provide complete control over image manipulation within Excel workbooks.

Quickstart: Insert, Extract & Remove Images in One Go

Use IronXL's intuitive API to add, get, and delete images from worksheets in just a few lines. This example shows how to insert an image, access it via the Images collection, and remove it - all without touching Interop.

  1. 1Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. 2Copy and run this code snippet.

    workSheet.InsertImage("logo.png", 1, 1, 3, 3);
    workSheet.RemoveImage(1);
    var firstImage = workSheet.Images[0];
    C#
  3. 3Deploy to test on your live environment

    Start using IronXL in your project today with a free trial
    arrow pointer

How Do I Add Images to Excel Worksheets?

To insert an image into a spreadsheet, use the InsertImage method, which supports various image types including JPG/JPEG, BMP, PNG, GIF, and TIFF. This capability is particularly useful when you need to create Excel charts in C# and supplement them with additional visual elements. Specify the top-left and bottom-right corners of the image to determine its dimensions, calculated by subtracting the column and row values.

The method signature requires five parameters: the image file path, and four integers representing the starting column, starting row, ending column, and ending row. The image will stretch or compress to fit within the defined cell range. For example:

  • For a 1x1 image size:
    • worksheet.InsertImage("image.gif", 5, 1, 6, 2);
  • For a 2x2 image size:
    • worksheet.InsertImage("image.gif", 5, 1, 7, 3);

When working with images in Excel, understand how IronXL manages them internally. Each inserted image receives a unique ID that follows a specific pattern.

Please note: The generated image IDs follow a pattern of 1, 3, 5, 7, and so on.

This odd-number sequence is crucial when referencing specific images for extraction or removal operations later.

using IronXL;

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);

workBook.SaveAs("insertImages.xlsx");

The InsertImage method provides flexibility in positioning and sizing images within your worksheet. Unlike manual image insertion in Excel, programmatic insertion ensures consistent placement across multiple files, making it ideal for generating reports or documents that require standardized formatting. This approach is particularly beneficial when working with Excel in C# without Interop, as it eliminates dependencies on Microsoft Office installations.

What Does the Inserted Image Look Like in Excel?

Spreadsheet with two colorful logos inserted in cells C4 and C7, showing successful image insertion

How Can I Extract Images From Excel Files?

To extract images from the selected worksheet, access the Images property, which provides a list of all images contained within the sheet. This feature is essential when you need to load Excel files without Interop and process their embedded visual content. From this list, you can perform various operations such as exporting, resizing, retrieving positions, and obtaining the byte data of each image. The image IDs follow an odd-numbered pattern, incrementing in the sequence of 1, 3, 5, 7, and so on.

The extraction process provides comprehensive access to image properties and data, enabling developers to:

  • Export images to various formats (PNG, JPEG, BMP, etc.)
  • Retrieve image positioning information for layout preservation
  • Access raw byte data for custom processing or storage
  • Resize images programmatically without external image processing libraries

This functionality proves invaluable when migrating content between different document formats or when building systems that need to catalog and manage visual assets from Excel files. The ability to extract images programmatically also supports automated quality control processes where images need validation or processing according to specific business rules.

using IronSoftware.Drawing;
using IronXL;
using IronXL.Drawing;
using System;
using System.Collections.Generic;

WorkBook workBook = WorkBook.Load("insertImages.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;

// 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");

    // Resize the image
    image.Resize(1,3);

    // Retrieve image position
    Position position = image.Position;
    Console.WriteLine("top row index: " + position.TopRowIndex);
    Console.WriteLine("bottom row index: " + position.BottomRowIndex);

    // Retrieve byte data
    byte[] imageByte = image.Data;
}

workBook.SaveAs("resizeImage.xlsx");
File explorer showing extracted PNG images and files in Documents/Replicate/bin/Debug/net6.0 directory
Spreadsheet showing three extracted images positioned in cells C2-E2, C5-E6, and C8-E10 with coordinate grid

How Do I Remove Images From Excel Worksheets?

Following the extract images example, you can easily remove any inserted image using its corresponding index number. Pass the image's ID number to the RemoveImage method to remove it from the worksheet. This operation is particularly useful when you need to edit Excel files in C# to clean up unwanted visual elements or prepare documents for different audiences.

The removal process is straightforward but requires understanding the image ID system. Since IronXL assigns IDs in an odd-number sequence (1, 3, 5, 7...), track these IDs when managing multiple images. Consider implementing a mapping system in your application to associate meaningful names with image IDs for easier management.

using IronXL;

WorkBook workBook = WorkBook.Load("insertImages.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;

// Remove image
workSheet.RemoveImage(3);

workBook.SaveAs("removeImage.xlsx");

For more complex scenarios involving multiple worksheets and images, explore managing worksheets to understand how image operations interact with worksheet-level operations. Additionally, when working with protected Excel files, refer to our guide on protecting Excel files to understand how image operations work with password-protected workbooks.

Frequently Asked Questions

How do I add images to Excel worksheets using IronXL?

You can use the `InsertImage` method in IronXL to add images to Excel worksheets. This method supports various image formats like JPG, PNG, GIF, and TIFF, allowing you to specify the top-left and bottom-right corners for precise placement.

Can IronXL remove images from Excel files?

Yes, IronXL enables you to remove images using the `RemoveImage` method. You'll need to reference the image's unique ID, which IronXL assigns in an odd-number sequence, to remove it from the worksheet.

How can I extract images from an Excel worksheet with IronXL?

To extract images, access the `Images` property of the worksheet in IronXL. This gives you a list of images that you can export, resize, or retrieve position data for, thus allowing for extensive manipulation.

What image formats are supported when adding images to Excel in IronXL?

IronXL supports a variety of image formats for insertion, including JPG, JPEG, BMP, PNG, GIF, and TIFF, ensuring compatibility with most standard image files.

How does IronXL assign IDs to images in Excel worksheets?

IronXL assigns a unique ID to each image in an odd-numbered sequence, such as 1, 3, 5, etc. These IDs are crucial for performing operations like extraction or removal.

Is it possible to programmatically resize images in Excel using IronXL?

Yes, you can programmatically resize images using the functionality provided by IronXL. This can be done during extraction by accessing the image's properties and adjusting the size.

Does IronXL require Excel Interop to manage images in Excel files?

No, IronXL does not require Excel Interop. It fully supports adding, extracting, and removing images from Excel files programmatically, eliminating the need for Microsoft Office dependencies.

How can I retain the position of images when extracting them from Excel files with IronXL?

When extracting images with IronXL, you can retrieve their position data, including row and column indices, to preserve layout and positioning information.

Why would I use IronXL for image manipulation in Excel workbooks?

IronXL simplifies image manipulation in Excel, allowing for consistent placement, extraction, and removal of images programmatically without reliance on manual processes or Excel Interop.

Can IronXL handle images in password-protected Excel files?

Yes, IronXL can work with password-protected Excel files. You may need to manage worksheet-level operations to ensure compatibility with image manipulation.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 2,237,574Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronXL.Excel
nuget.org/packages/IronXL.Excel/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronXL"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronXL to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronXL.dll"

Licenses from $999

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