I'm doing an application in Delphi (with Embarcadero XE3) that requires Excel automation.
I need to insert a TeeChart, generated by my app, into a XLS file. I export the chart as BMP as follows:
// Globals.getEnvTempPath() returns the temp directory of the current Windows user.
bmpPath := Globals.getEnvTempPath() + 'enp.bmp';
// enpChart is my TeeChart instance.
enpChart.SaveToBitmapFile(bmpPath);
The image is exported correctly.
Then I insert the image in Excel as follows:
//WkBook is the Workbook
sheet := WkBook.Worksheets[1];
{ params: @rutaImagen, @? @? @xPosicion @yPosicion @? @? }
sheet.shapes.addpicture(bmpPath,False, True, 145, 125, -1, -1);
The insert is successful, but the Chart gridlines do not not line up (vertically) with the WorkSheet gridlines:
Any ideas how solve this ?.
Three possible solutions: