HotXLS Docs

AddPicture method

Creates a picture from an existing file or TBitmap object. Returns a TXLSPicture object that represents the new picture.

Syntax

function AddPicture(FileName: WideString): TXLSPicture;
function AddPicture(Bitmap: TBitmap; Transparent: boolean = flase): TXLSPicture;
function AddPicture(Bitmap: TBitmap; TransparentPoint: TPoint): TXLSPicture;
FileName Required WideString. The file from which the picture is to be created.
Bitmap Required TBitmap. TBitmap object from which the picture is to be created.
Transparent Optional Boolean. True to use color of pointer[0, 0] as transparent color; False - Transparent color is undefined. Default value is False
TransparentPoint Optional TPoint. Specifies the pointer with transparent color.

Remarks

HotXLS supports the following image types: BMP, JPEG, PNG, EMF, WMF. Pictures supported only for MS Excel 97 and later file format

Example

This example creates new picture on sheet one.

With Workbook.Sheets[1] do begin
  Cells[2, 2].Select; //the upper-left corner of the picture
  Shapes.AddPicture('image.jpg');
end;
This example creates new picture using TBitmap object.

Var Bitmap: TBitmap;
begin
  ...
  With Workbook.Sheets[1] do begin
    Cells[2, 2].Select; //the upper-left corner of the picture
    Bitmap := TBitmap.Create;
    Bitmap.LoadFromFile('image.bmp');
    with Shapes.AddPicture(Bitmap) do begin
      //speicify White color as transparent
      TransparentColor := rgb(255,255,255);  
    end
    Bitmap.Free;
  end;
  ...
end
This example creates new picture and specifies white color as transparent.

With Workbook.Sheets[1] do begin
  Cells[2, 2].Select; //the upper-left corner of the picture
  with Shapes.AddPicture('image.jpg') do begin
    TransparentColor := $FFFFFF;
  end;
end;