Print from array-source....runtime creation

edited February 2009 in FastReport 4.0
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

  • gordkgordk St.Catherines On. Canada.
    edited 9:08PM
    no need to set band width when created a band's width is that of the design page.
    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.
  • edited 9:08PM
    gordk wrote: »
    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.
    hm... i don't have datasource. Grid is parameter, and only grid is a source... the only way is iterate through the grid indexes.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.