IT/Delphi

Tee Chart 를 QuickReport로 출력하는 방법

비와바람 2009. 11. 23. 10:47


Delphi 2007에서는 Tee Chart와 QuickReport가 연동되지 않는다.

퀵리포트를 pro버전 사면 되는거 같긴 한데, 확실치는 않고..

그래서 델마당에 문의한 결과, metaFile로 받아서 이미지로 출력하는 방법을 얻어냈다.

(대단하신 분이다.. ^^)

그걸 내 입맛에 맞게 조금 수정했다.

procedure TfrmChartPrt.qrpChartLandScapeBeforePrint(Sender: TCustomQuickRep;
  var PrintReport: Boolean);
var
    mtMeta      : TMetaFile;
    alAlign : TAlign;
begin
    alAlign := gchtChart.Align;  //속성백업
    gchtChart.Align := alnone;  //속성을 초기화 한다.

    gchtChart.Width    := qimgLandScape.Width;
    gchtChart.Height   := qimgLandScape.Height;

    mtMeta  := gchtChart.TeeCreateMetafile(TRUE, gchtChart.GetRectangle);

    qimgLandScape.Picture.Metafile.Assign(mtMeta);

    gchtChart.Align := alAlign;  //백업된 속성을 복구한다.
end;