Insert Image from File into Worksheet?

Hi Adrian,

Is it possible to insert an image (png) from a file into a worksheet?

I looked in the help and demos and couldn't find anything,

Thanks - Steve


Yes, of course. Please take a look at the "getting started" demo, there you will find the lines:

	//Get path for images from disk.
  PathToImage := DataFolder  + 'poweredbyflexcel.png';

  //Add a new image on cell F2
    TClientAnchor.Create(TFlxAnchorType.MoveAndResize, 2, 0, 6, 0, 5, 0, 8, 0),
    PathToImage, 'My image'));

And you can try with APIMate too, it will tell you how to insert an image if you insert it in Excel.  The only part that can be a little trick is setting the image position: Images in an xls file are stored as (row1, col1) to (row2, col2) with an offset of the percent of the cell where the image starts and ends. But TClientAnchor constructor also has a constructor that takes the width and height of the image in pixels and it will calculate the row2,  col2 an the offsets for you.

Thanks Adrian - sorry I missed this,

- Steve