Hi,
There is no built in way (that I remember on top of my head)to do it with the api, but you can do it with reports. If yo look at the code FlexCelReport uses, you need to use TExcelMetrics.RowMult and ColMult to convert from excel! Internal units to points (1/72 of an inch)
Here is the relevant code from FlexCelReport:
TImageHAlign.Center:
begin
begin
cw := ev.DataFile.GetColWidth(ImgProps.Anchor.Col1) / TExcelMetrics.ColMult(ev.DataFile);
Dx1Pix := Convert.ToInt32(((cw - ev.Width) / 2) + ColOffs);
end;
end;
And it is similar for rows. Once you have e erything in points, it is simple to center the image and keep the ratio.
I am typing this from a tablet and it is no fun, so sorry I can't send a more complete code example. If you still need it, I can send it when I come back home in about a week. But rowmult/colmult should be all you need. It is what flexcel uses everywhere to render the files to pdf, html or images
Aha! Thanks for that, and sorry to force you to support me on a tablet! :-)