Skip to content

How can I insert an image

D0g4r33 edited this page Mar 3, 2021 · 5 revisions
  1. IXLWorksheet.AddPicture - add a picture to a worksheet
  2. IXLPicture.MoveTo - move the picture where you want it to be
using (var wb = new XLWorkbook())
{
  var ws = wb.AddWorksheet("Sheet1");

  var imagePath = @"c:\path\to\your\image.jpg";

  var image = ws.AddPicture(imagePath)
      .MoveTo(ws.Cell("B3"))
      .Scale(0.5); // optional: resize picture
      
  wb.SaveAs("file.xlsx");
}

The ability to add pictures was added in v0.88 of ClosedXML

FAQ

Examples

Real world scenarios

Time Savers

Performance and Memory

Misc

Inserting Data/Tables

Styles

Ranges

Rows

Columns

Page Setup (Print Options)

AutoFilters

Comments

Dev docs

Clone this wiki locally