AddImage on Chart sheet?

Should it be possible to add an image on a chart sheet (not an embedded chart)?

I can add the image on a regular datasheet.
ApiMate gives me code from a file with an image on a chartsheet, but when I run it I can't see the image anywhere. If I unzip the xlsx file I can see a PNG file in there, it just doesn't see to want to appear on the graph....

Hi,
The code generated by APIMate is wrong in this case: You don't have to add the image to the chart sheet, but to the chart inside the chart sheet.

The code should really be:

//Images
fs := TFileStream.Create('imagename.png', fmOpenRead or fmShareDenyNone);
try
ImgProps := TImageProperties_Create();
ImgProps.Anchor := TClientAnchor.Create(true, TFlxAnchorType.MoveAndResize, 618, 0, 1018, 0, 2323, 0, 1663, 0);
ImgProps.ShapeName := 'Picture 2';
var chart := xls.GetChart(1, '');
chart.AddImage(fs, ImgProps);
finally
fs.Free;
end;

but... this won't compile because there is no AddImage in IXlsChart. There is AddAutoshape but not AddImage, and this is just something we forgot. There should be a method to add an image to a chart, and we will be adding one for the next version (and fixing APIMate so it enters the image in the right place)

Adrian,

Thanks as always for your rapid and thorough replies.

APImate can be both such a positive and a negative. It is positive because we can rely on finding how to do most stuff very easily. But when it has a bug, it can lead us down the rabbit-hole.

I am glad that I seem to be keeping up my record of finding the little intricate bits that get missed. I hope that this is a valuable help to you too.

I look forward to a fix for this as we are now moving to get this in to our production code and finally retire using Excel through OLE-automation. With that in mind do you have an estimate of when this will be available in the new release. We will be able to continue working towards our own release, but that can not happen until this issue is fixed as it is needed for our corporate branding on the graphs.

Many thanks

If everything goes right, we should be able to do a release this week. The functionality should be all there, we are just missing a public method to add it.

1 Like

Well, as usual sorry for the delay, it took longer than expected... but I think it turned out ok.
In this new release you can actually add the image with both xls.AddImage and Chart.AddImage (when in a chart sheet) and both will work. APIMate code should be better now too.

@adrian

I understand. Schedules are not easy to set 100% accurately.

Looking forward to trying this out next week when I can download the update.

It is because the product and the new features are so good that we are impatient to get updates!! :slight_smile:

@adrian . Tested and working perfectly in our application.

Thanks