Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

Bad performance on tableGrid style

Hi,
I have a report that should print a sort of Gantt:
the query has a row for every project phase and there are 53 columns (one for the project name and theother 52 corresponds to weeks, their value is 1 or 0)

In the report I have a TableGrid with one Row and 53 columns in the Detail Section. I want the columns to be red if the corresponding value in the Query is 1, and blank if 0.

In the DetailBeforePrint Event I added this code:

procedure DetailBeforePrint; var cellIndex: integer; cell: TppTableCell; value: integer; begin for cellIndex := 0 to TableRow.CellCount -1 do begin value := MyQuery[PadLeft(IntToStr(cellIndex+1), 2, '0')]; //This is because Query fields are '01' to '52' cell := TableGrid.Cells[0, cellIndex] ; if valore = 1 then cell.Brush.Color := clRed else cell.Brush.Color := clWindow; end; showmessage('One row is done'); end; end;


It works, but it's terribly slow.
I added a showmessage at the end of the loop to get a feeling of the time it takes to complete one row. The thing I find strange is that the first rows are completed quite quickly, but it takes more and more time as we go on.

Did I make some terrible mistake? Is there a way to seed it up?

Comments

  • Sorry for the bad formatting:

    procedure DetailBeforPrint;
    var
    cellIndex: integer;
    cell: TppTableCell;
    value: integer;


    begin

    for cellIndex := 0 to TableRow.CellCount -1 do
    begin
    value := TutteLeFasi_Corretta[PadLeft(IntToStr(cellIndex+1), 2, '0')]; //because fields are '01' ... '52'
    cell := TableGrid.Cells[0, cellIndex] ;
    if valore = 1
    then cell.Brush.Color := clRed
    else cell.Brush.Color := clWindow;
    end;

    showmessage('New Row created');
    end;

    end;
  • Hi Giuseppe,

    Is the code implemented in Delphi or the RB Calc workspace? If Calc workspace, try a test with Delphi code. If that is faster, create a RAP pass-thru function that can be called from Detail BeforePrint.

    If you would like to create an example I can build and run in the debugger, I can research it. Please use standard Delphi components and RB. Copy data to TClientDataSets. Send zip, include only dpr, pas, dfm. Send to support@



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • It's the RB Calc workspace. At the moment I'm not willing to modify the main Delphi application, so I was trying to understand if something was bad on the logic of my code, since it looks like for every iteration of the DetailBeforePrint, it's moving across the already completed lines, so at every new row it takes longer and longer

    Anyway I will try to create an example of this to show you
Sign In or Register to comment.