Author Topic: Runtime editing of report output  (Read 763 times)


  • Newbie
  • Posts: 5
Runtime editing of report output
« on: March 21, 2023, 07:13:05 pm »
Hi, I'm wondering if I'm barking up the wrong tree here.  I'm trying to recreate the document generation process in a legacy application using LazReports to generate the repeating content (the data bands), and using the generated report as a section of the more complex document.  The legacy system's document generator appears as a word processor with the ability to insert sections which may be headers, footers, or report bands, along with a few additional features.

I've been checking out the export filters in LazReports, trying to use the ExportTo function to load a the report output into a TStream. From there, loading the report output into a RichText or RichMemo (TKMemo, currently) during runtime.   

So far however, the frExportFilter option for writing to a TStream doesn't seem to do anything.

The code below compiles and runs, but nothing gets displayed in the TKMemo object I'm trying to load.

Thanks for any suggestions you might have.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button2Click(Sender: TObject);
  2. var
  3.   txtStream: TStringStream; //I've tried Memory, File, and StringStreams, all with the same result
  4. begin
  5.   AppDirectory := ExtractFilePath(ParamStr(0));
  6.   frReport.LoadFromFile(AppDirectory+'Charges.lrf');
  7.   frReport.PrepareReport;
  8.   frReport.ShowReport;  //Added this line just to ensure the report did get generated
  9.   txtStream := TStringStream.Create;
  10.   frReport.ExportTo(TfrExportFilter,txtStream) ;
  11.   txtStream.Position := 0;
  12.   try
  13.     Page1.Blocks.LoadFromRTFStream(txtStream);
  14.   finally
  15.     FreeAndNil(txtStream);
  16.   end;
  17. end
//Page1 is a TKMemo, in case it matters.


TinyPortal © 2005-2018