Board index » delphi » QuickReport without database

QuickReport without database

How can I print a quickreport without using a database?
 

Re:QuickReport without database


Quote
"Brian" <t480...@hotmail.com> wrote in message news:3d36109a$1_1@dnews...
> How can I print a quickreport without using a database?

You use the OnNeedData method of the QuickReport - a bit like this:

(It's just a cut and paste with some cut out of it, but you should be able
to see that I am iterating through a TList which has a bunch of TPluObjects
in it containing the information for each record I want to print.

procedure TrepA4Invoice.QuickRep1NeedData(Sender: TObject;
  var MoreData: Boolean);
var
  lPluObject : TPluObject;
  lUnitPrice : double;
  lExGSTAmount : double;
  lGSTAmount : double;
begin

  if (PluObjectListIndex > fTransactionObject.PluObjectList.count - 1) then
    begin
    MoreData := false;
    exit;
    end
  else
    MoreData := true;

  lPluObject := fTransactionObject.PluObjectList[PluObjectListIndex];
  lblProductCode.caption := lPluObject.ProductCode;
  lblDescription.caption := lPluObject.Description;
  // etc...

  inc(fPluObjectListIndex);

end;

Make sure you have the QuickRep1.PrintIfEmpty := true;

HTH

Josh

Re:QuickReport without database


Quote
Brian wrote:
> How can I print a quickreport without using a database?

Say you have an array or similar thing. I have a quick test prog using a
TStrings object:

procedure TQuickReport2.QuickRepBeforePrint(Sender: TCustomQuickRep;
   var PrintReport: Boolean);
begin
   iData := 0;
end;

procedure TQuickReport2.QuickRepNeedData(Sender: TObject;
   var MoreData: Boolean);
begin
   MoreData := iData < Data.Count;
   if MoreData then begin
     lblData.Caption := Data[iData];
     Inc(iData);
   end{if};
end;

Other Threads