开发者

FastReport - How to displaying data in the form of table?

How can i display data in the form of table in the FastReport ?

Edit

I mean ,I want to create a repo开发者_开发问答rt like this : (with tabular format).

FastReport - How to displaying data in the form of table?


The easiest way to use FR wizard

from FR File menu > new > Standard report wizard

when you reach the "Layout" page, choose tabular from layout then OK


I think you need to build the grid yourself. Here's a bit of code that builds a grid layout to get you started. You will need to adjust the column widths and add the formatting code (memo.frame) to get your desired look.

procedure CreateHeader(frxDataset: TfrxDBDataSet; Page: TfrxReportPage);
var
  i: Integer;
  X, Y, ThisWidth: Extended;
  HeaderMemo: TfrxCustomMemoView;
  Column: TcxGridDBColumn;
begin
  Band := TfrxPageHeader.Create(Page);
  Band.CreateUniqueName;
  Band.SetBounds(0, 0, 0, fr01cm * 7);
  Band.Height := edtHeightHeader.Value;

  HeaderMemo := CreateMemo(Band);
  HeaderMemo.SetBounds(0, 0, PageWidth, 0);

  // Set memo style
  // Or just add a frame HeaderMemo.Frame....
  HeaderMemo.Style := 'Header line';

  X := 0;
  Y := 0;

  Memo := CreateMemo(Band);
  Memo.SetBounds(0, Y, X, fr01cm * 6);
  Memo.Height := Band.Height - 1;

  for i := 0 to pred(frxDataset.Fields.Count) do
  begin
    ThisWidth := 100;

    Memo := CreateMemo(Band);
    Memo.SetBounds(X, Y, ThisWidth, fr01cm * 6);

    Memo.Text := frxDataset.Fields[i].FieldName;

    // Set memo style
    // Or just add a frame HeaderMemo.Frame....
    Memo.Style := 'Header';

    Memo.Height := Band.Height - 1;

    X := X + ThisWidth;
  end;

  HeaderMemo.Height := Band.Height;
end;

procedure CreateFastReportDataBand(frxDataset: TfrxDBDataSet; Page: TfrxReportPage);
var
  i: Integer;
  X, Y, ThisWidth: Extended;
begin
  Band := TfrxMasterData.Create(Page);
  Band.CreateUniqueName;
  Band.SetBounds(0, CurY, 0, 0);
  Band.Height := edtHeightData.Value;

  TfrxMasterData(Band).frxDataset := frxDataset;

  X := 0;
  Y := 0;

  for i := 0 to pred(frxDataset.Fields.Count) do
  begin
    ThisWidth := 100;

    Memo := CreateMemo(Band);
    Memo.SetBounds(X, Y, ThisWidth, fr01cm * 5);
    Memo.Dataset := frxDataset;
    Memo.DataField := frxDataset.Fields[i].FieldName;

    // Set memo style
    // Or just add a frame HeaderMemo.Frame....
    Memo.Style := 'Data';

    Memo.Height := Band.Height - 1;

    X := X + ThisWidth;
  end;
end;

It should work ok, but I've not had a chance to test since decoupling it from my application.


It will be possible using Framing Property of Memos.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜