Image Markers

Aspose.Cells smart markers support image markers too. This section shows you how to insert pictures using smart markers.

Image Parameters

Smart marker parameters for managing images.

  • Picture:FitToCell - Auto-fit the image to the cell’s row height and column width.
  • Picture:ScaleN - Scale height and width to N percent.
  • Picture:Width:Nin&Height:Nin - Render the image N inches high and N inches wide. You can also sepecify Left and Top positions (in points).
 string FilePath = @"..\..\..\Sample Files\";

string FileName = FilePath + "Image Markers.xlsx";

//Get the image data.

byte[] imageData = File.ReadAllBytes(FilePath + "Aspose.Cells.png");

//Create a datatable.

DataTable t = new DataTable("Table1");

//Add a column to save pictures.

DataColumn dc = t.Columns.Add("Picture");

//Set its data type.

dc.DataType = typeof(object);

//Add a new new record to it.

DataRow row = t.NewRow();

row[0] = imageData;


//Add another record (having picture) to it.

//imageData = File.ReadAllBytes(FilePath + "Desert.jpg");

//row = t.NewRow();

//row[0] = imageData;


//Create WorkbookDesigner object.

WorkbookDesigner designer = new WorkbookDesigner();

//Open the temple Excel file.

designer.Workbook = new Workbook(FileName);

//Set the datasource.


//Process the markers.


//Save the Excel file.


Download Sample Code