Home RAP

Change Font for all textobjects when output goes to Excel.

edited April 2016 in RAP
Hi,

A customer uses a report to print/preview and also exports this report
to Excel. Headers and footers etc are hidden when creating a Excel
outputfile. This works fine.
Now he would like the font used when exporting to Excel to be Arial
Norrow 10pt for all text.
The report contains several subreports.

Can I iterate over all textobjects from RAP and change the font when
outputting to Excel?

Using D2007, RB14.08 and RAP.

--
Kind regards,

Jeroen Röttink
JR-soft software solutions

Comments

  • edited April 2016
    I found an example iterating over all report components and translated
    it to RAP. Problem seems that recursive code structures are not allowed.
    Chicken-and-egg problem. Procedure doesn't compile because recursive
    call can't be evaluated.

    procedure UpdateReportFont(AReport: TppCustomReport);
    var Component: TppComponent;
    SubReport: TppSubReport;
    X, Y: integer;
    Band: TppBand;
    begin
    for X := 0 to AReport.BandCount-1
    do begin
    Band := AReport.Bands[X];
    for Y := 0 to Band.ObjectCount-1
    do begin
    Component := Band.Objects[Y];
    if (Component is TppCustomText)
    then Component.Font.Name := 'Arial Narrow'
    else if (Component is TppSubReport)
    then begin
    // recurse into subreport
    SubReport := Component as TppSubReport;
    UpdateReportFont(SubReport.Report); // <-- problem here
    end;
    end;
    end;
    end;

    --
    Kind regards,

    Jeroen Röttink
    JR-soft software solutions
  • edited April 2016
    Probably your best option is to write a Pass-thru function, that takes a
    TppCustomReport a parameter, to do it. Should only take a few minutes to
    implement.

This discussion has been closed.