What's wrong with this code in delphi?

2

In the onCreate of the mainform, I have the following code:

procedure TForm1.FormCreate(Sender: TObject);
begin
 QuickRep1.Prepare;
 QuickRep1.Printer.Load('arquivo.qrp');
 QuickRep1.ExportToFilter(TQRAsciiExportFilter.Create('teste.txt'));
 QuickRep1.Free;
end;

It should open a QRP file and save as TXT. It even creates the test.txt, but the file is blank, with 0kb. Where am I going wrong?

    
asked by anonymous 16.02.2017 / 01:44

1 answer

1

Try this:

Create 2 new variables (in uses interface declare: QRPrntr ):

  vFilterLibrary : TQRExportFilterLibraryEntry;
  vExportFilter  : TQRExportFilter;     

After the Prepare:

  vFilterLibrary := QRExportFilterLibrary.GetFilterByExtension('txt');
  vExportFilter  := vFilterLibrary.ExportFilterClass.Create(vNomeAnexo);
  QuickRep1.ExportToFilter(vExportFilter);

What we are doing is to find the Filter by extension, then we ask him to create the file (correct form).

Note: For this procedure to work, the report form that will be exported must have a Filter that exports with the extension txt!

    
16.02.2017 / 17:18