Question
“How do I show a TeeChart created on a form as an image on a report?”
Solution
Use the TeeChart routine TeeCreateMetafile to export the chart to an image then assign it to a TppImage on a report.
Download: ChartAsImage.zip
Sample Delphi code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
procedure TForm1.Button1Click(Sender: TObject); var lMetaFile: TMetaFile; lRect: TRect; begin lRect.Left := 0; lRect.Top := 0; lRect.Right := ppImage1.spWidth; lRect.Bottom := ppImage1.spHeight; //Create a metafile from the chart lMetaFile := Chart1.TeeCreateMetafile(True, lRect); //Assign the metafile to a TppImage component ppImage1.Picture.Metafile.Assign(lMetaFile); ppReport1.Print; lMetaFile.Free; end; |