How to insert a table which grows dynamically and fill the data from CPP code

Hi,

I am a beginner to FastReport. My requirement is to have a table in the TfrxReport and the data of the rows and columns has to be filled from the back-end cpp code rather than from a DBDataset.

I couldn't find much of information in internet on how to do this. Any suggessted idea on how to draw the table and fill the data or any related tutorial will be helpful.
FYI: I'm using FastReport FMX 2 version on a Embercadero IDE.

Comments

  • LurkingKiwiLurkingKiwi Wellington, New Zealand
    edited 9:51PM
    What you need is a user dataset. In VCL this is TfrxUserDataSet, and there are examples supplied with FR.
    You supply a function which is passed a field name, and your code then looks up the requested data.
    I use code like the following in Delphi for printing a 2D string array containing blanks or integer text using dummy column names like ColA, ColB etc:
    ArrayDS.RangeBegin := rbFirst;
    ArrayDS.RangeEnd := reCount;
    ArrayDS.RangeEndCount := High(StringArray);

    and the following function is assigned to the OnGetValue event:

    procedure TForm1.frxArrayGetValue(const VarName: string; var Value: Variant);
    var
    ci: Integer;
    begin
    if (length(VarName) = 4) and (copy(Varname,1,3) = 'Col') then
    begin { Only change value if it's our column name, this is called with full expressions before decomposing into fields }
    ci := Ord(UpCase(VarName[4])) - Ord('A');
    if StringArray[ArrayDS.RecNo, ci] = '' then
    Value := NULL { This shows as a blank in the preview, and as an empty cell in Excel - exactly what's wanted }
    else
    Value := StrToInt(StringArray[ArrayDS.RecNo, ci]);
    end
    end
    end;

Leave a Comment