Using data from an array in a Report

Asked

Viewed 150 times

2

I have a matrix like this that is being filled in Runtime:

MatSort[0][0] - Nome1
MatSort[0][1] - InfoNome1
MatSort[1][0] - Nome2
MatSort[1][1] - InfoNome2

But I don’t know how to reference the data from this matrix in fast-Reports to generate a report with the configuration:

Nome1 - Infonome1

Nome2 - Infonome2

Remembering that the Name and Info data should be next to each other and the names should be separated by a line.

1 answer

2


You can inject this data into the report . But it’s easier and convenient in the report to work with datasets.

Why not fill in a Tclientdataset (A memory dataset that doesn’t need to be connected to the BD) with the matrix data before you print the report, and use the report linked to that dataset?

There are several ways to do it but I would suggest something like:

  1. Place Tclientdataset where you have fastreport (Form or Datamodule)
  2. Create Name; Infoname fields in Tclientdataset
  3. You do something like (Cds being the name of Tclientdataset)

for i:=0 to limiteMatriz-1 do
begin
cds.append;
cdsNome.value:=MatSort[i][0];
cdsNomeInfo.value:=MatSort[i][1];
cds.post;
end;

Now you can connect the datasource to the report (for this you can easily find documentation)

  • You could edit your question with an example code to fill this data in the dataset?

  • I edited it to give you an example

  • very good, thanks for the help!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.