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

Searching for object types

edited August 2002 in General
Is there any way I can cycle through a report (loaded from a template) and
find all objects of a particular type (say a TeeChart) and get a handle to
it?

Comments

  • edited August 2002
    Yes you can. Just iterate through the Report bands and then for each band
    iterate through the report objects. Check to see if that object type is what
    you want and you have it.
    For Idx :=0 To Pred(ppReport1.BandCount) Do
    Begin
    For Jdx :=0 To Pred(ppReport1.ObjectCount) Do
    Begin
    If ppReport1.Bands[Idx].Objects[Jdx] is TppTeeChart Then
    ShowMessage('I got it!');
    End;
    End;
    Alternatively if you know the name of your object you are seeking then you
    can use the ObjectByName function to see if it is a valid object and use the
    index to get the same.

    HTH,
    Vikram

  • edited August 2002
    Cheers, works really well.
  • edited August 2002
    Hi David,

    here some code published by Alexander Kramnik (Digital-Metaphors) for a
    similar problem:


    If you actually want to write a conversion utility you can simply iterate
    through your reports and then iterate through all the object in the report
    using the loop below.

    procedure UpdateReport(aReport: TppReport)'

    for (liBands := 0 to aReport1.BandCount - 1) do
    for (liObjects := 0 to aReport1.Bands[liBands].ObjectCount - 1) do
    begin
    lObject := aReport1.Bands[liBands].Objects[liObject];
    if (lObject is TppSubreport) then
    UpdateReport(TppSubreport(aReport).Report)
    else if (lObject is TppComponent) then
    begin
    lComponent := TppComponent(lObject);
    if lComponent.IsDataAware
    // update lComponent.DataPipeline and lComponent.DataField
    end;
    end;


    HTH,
    Chris Ueberall;

This discussion has been closed.