elite
elite

Reputation: 191

All needed DatabaseFields referenced in FastReport file

Does anybody know how to get all Database-Fields needed by a FastReport report?

Background: Usually all the data for our reports come directly from delphi and not via a direct database connection. We have a editor for editing fast report files. We want to show a preview of the reports with data input by the user. Therefore we need to know all the used datasets and the fields of the datsets needed by the report.

Getting the needed datasets of the report can be done with the property:

var
  rpReport: TfrxReport
begin
  rpReport.DataSets 

But how can we get the number and the names of the fields of the datasets?

Upvotes: 0

Views: 1299

Answers (2)

elite
elite

Reputation: 191

For me it worked by parsing the .fr3 file, that is an xml file.

I use the following regex to get all the fields (including fields just used by expressions):

mDatasetName + '\.&#34;(?<fieldname>[^&]+)&#34;'

where mDatasetName is the name of the dataset the fields are needed for. All the names of the datasets I get by the collection:

for I := 0 to rpReport.DataSets.Count - 1 do
  mDatasetName := rpReport.Datasets[I].DatasetName;

Upvotes: 0

katz
katz

Reputation: 76

Every TfrxDataSet descendant has public FieldsCount and GetFieldList functions.

var
  fl: TStringList;

 fl := TStringList.Create;
 rpReport.DataSets[0].DataSet.GetFieldList(fl);

Upvotes: 1

Related Questions