Skip to footer content

How to Add, Extract, and Remove Images from Worksheets

In this tutorial, we delve into the process of handling images within Excel spreadsheets using the IronXL library in C#. The session begins with the installation of the IronXL library via the NuGet package manager. First, we import the necessary namespaces for drawing and IronXL functionalities. A new Excel workbook is created, and its default worksheet is selected. The 'insert image' method is employed, which requires the image file path and its dimensions, defined by the top left and bottom right corners of the spreadsheet.

In the code above, we:

  • Created a new workbook and selected the default worksheet.
  • Inserted an image into specified cell ranges ("A1" to "D4").
  • Retrieved images from the worksheet, converted them into bitmap objects, and saved them as PNG files using unique names based on their IDs.
  • Demonstrated the removal of images from the worksheet using their IDs.
  • Saved the final state of the workbook into a new Excel file named 'insert_images.xlsx'.

Upon running the project, the Excel file successfully displays the added images, appropriately sized and positioned. The tutorial concludes with a brief on checking the extracted photos saved as individual PNG files with unique IDs. Viewers are encouraged to engage with the content by liking, subscribing, and trying out the software through a trial subscription.

Further Reading: How to Add, Extract, and Remove Images from Worksheets

Regan Pun
Software Engineer
Regan graduated from the University of Reading, with a BA in Electronic Engineering. Before joining Iron Software, his previous job roles had him laser-focused on single tasks; and what he most enjoys at Iron Software is the spectrum of work he gets to undertake, whether it’s adding value to sales, technical support, product development or marketing. He enjoys understanding the way developers are using the Iron Software library, and using that knowledge to continually improve documentation and develop the products.
Talk to an Expert Five Star Trust Score Rating

Ready to Get Started?

Nuget Passed