Print from array-source....runtime creation
Hi, i'm using FastReport 4.5.13...first day of work with FR and i need to create raport...dynamically [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" />
In the begining...sorry form my english..
I have two problems
- creating raport is very slow
- i can print only one page
My delphi code :[/img]
use ..... Printers;
procedure TForm1.GridToFastReport2(Grid : TMyGrid;);
var
  Page:TfrxReportPage;
  Band:TfrxReportTitle;
  Memo:TfrxMemoView;
  ReportTitle : TfrxReportTitle;
  i, j, iWidth, iLeft, iTop, iColumns,iColumn, iRows, iRow : integer;
  Column : TMyGridColumn;
  sValue : string;
begin
  iLeft := 10;
  iTop := 10;
 Â
  frxReport1.Clear;
  Page := TfrxReportPage.Create(frxReport1);
  Page.Orientation := poLandscape;
  Page.LeftMargin := 6;
  Page.RightMargin := 6;
  Page.TopMargin := 6;
  Page.BottomMargin := 6;
  Band := TfrxReportTitle.Create(Page);
  Band.CreateUniqueName;
  band.Width := 1200;
  iRows :=Grid.RecordCount;
  iColumns := Grid.ColumnCount;
  for i := 0 to iColumns - 1 do
  begin
    iTop := 10;
    Column := Grid.Columns.Column[i];
    if iLeft + Column.Width > 1400 then Continue;
    with TfrxMemoView.Create(Band) do
    begin
      iWidth := Column.Width;
      CreateUniqueName;
      HAlign := haLeft;
      Font.Size := 8;
      Font.Name := 'Tahoma';
      SetBounds(iLeft,iTop,iWidth,15);
      iLeft := iLeft + iWidth;
      Text := Column.Caption;
    end;
    iTop := iTop + 16;
    for j := 0 to iRows - 1 do
    begin
      sValue := Grid.ActiveView.Cell[j,i];
      with TfrxMemoView.Create(Band) do
      begin
        iWidth := Column.Width;
        CreateUniqueName;
        HAlign := haLeft;
        Font.Size := 8;
        Font.Name := 'Tahoma';
        SetBounds(iLeft-iWidth,iTop,iWidth,15);
        iTop := iTop + 16;
        Text := sValue;
      end;
    end;
  end;
  frxReport1.ShowReport(true);
end;
Thanks for the answer.
Comments
you have only created a title band with memoviews, you will see only one page
in order to produce more records you need to use a masterdataband and set it's rowcount to the number of rows you need or connect to a datasource.
the loss of speed is probably due to you having to iterate through the grid.