动态创建Fastreport
来源:互联网 发布:儿童上网控制软件 编辑:程序博客网 时间:2024/05/16 14:39
动态创建Fastreport分以下几个步骤:
1.首先清空Fastreport,定义全局变量,并加载数据集
frReport.Clear;
frReport.DataSets.Add(frxDBDataset1);
DataHeight :=28;
DataWidth :=80;
FirstTop := 50;
FirstLeft := 15;
2.创建frxReportPage,并设置纸张大小
Page := TfrxReportPage.Create(frReport);
Page.CreateUniqueName;
page.Orientation := poLandscape;
Page.SetDefaults; //默认大小
//Page.PaperWidth := 210;
//Page.PaperHeight := 297;
3.生成PageBand,并指定高度
Band := TfrxPageHeader.Create(Page); //页首
Band.Top := 10;
Band.Height := 150;
BandFoot := TfrxColumnFooter.Create(Page); //页脚
BandFoot.Top := 10;
BandFoot.Height := 50;
4.画页脚栏
//画操作员
memFoot := TfrxMemoView.Create(BandFoot);
with memFoot do
begin
CreateUniqueName;
HAlign := haLeft;
VAlign := vaCenter;
Memo.Text := '操作员:程序员';
SetBounds(40, 10, 150, 20);
ParentFont := False;
Font.Name := '宋体';
Font.Size := 10;
end;
//画打印时间
memFoot := TfrxMemoView.Create(BandFoot);
with memFoot do
begin
CreateUniqueName;
Align := baLeft;
HAlign := haLeft;
VAlign := vaCenter;
Memo.Text := '打印时间:' + FormatDateTime('yyyy-mm-dd hh:mm:ss', Now);
SetBounds(280, 10, 270, 20);
ParentFont := False;
Font.Name := '宋体';
Font.Size := 11;
end;
5.画标题栏
//画标题
Memo := TfrxMemoView.Create(Band);
with Memo do
begin
CreateUniqueName;
Align := baCenter;
Memo.Text := '固定资产余额汇总表';
Frame.Typ :=[ftBottom];
Frame.BottomLine.Style :=fsDouble; //行类型
Top := FirstTop;
Height := 30;
AutoWidth :=True;
HAlign := haCenter;
ParentFont := False;
Font.Name := '黑体';
Font.Size := 16;
end;
//画单位
Memo := TfrxMemoView.Create(Band);
with Memo do
begin
CreateUniqueName;
HAlign := haLeft;
VAlign := vaCenter;
Memo.Text := '单位:************';
FirstTop := FirstTop + 40;
FirstWidth := 200;
FirstHeight := 30;
SetBounds(40, FirstTop, FirstWidth, FirstHeight);
ParentFont := False;
Font.Name := '宋体';
Font.Size := 10;
end;
//画日期
Memo := TfrxMemoView.Create(Band);
with Memo do
begin
CreateUniqueName;
Align := baLeft;
VAlign := vaCenter;
HAlign := haLeft;
Memo.Text := '日期:' + FormatDateTime('yyyy-mm-dd', Date);
FirstWidth := 10 + FirstWidth + 200;
FirstLeft := FirstLeft + FirstWidth;
SetBounds(FirstLeft, FirstTop, 200, FirstHeight);
ParentFont := False;
Font.Name := '宋体';
Font.Size := 10;
end;
//画页码
Memo := TfrxMemoView.Create(Band);
with Memo do
begin
CreateUniqueName;
Align := baLeft;
HAlign := haLeft;
VAlign := vaCenter;
Memo.Text := '第[Page#]/[TotalPages#]页'; //[]中括起来的是FastReport系统变量
FirstWidth := 10 + FirstWidth;
FirstLeft := FirstLeft + 200;
SetBounds(FirstLeft, FirstTop, 100, FirstHeight);
HAlign := haCenter;
ParentFont := False;
Font.Name := '宋体';
Font.Size := 10;
end;
for i := 1 to qryPrn.FieldCount - 4 do
begin
//画数据集的标题
Memo := TfrxMemoView.Create(Band);
Memo.CreateUniqueName;
Memo.ParentFont := False;
Memo.Font.Name := '宋体';
Memo.Font.Size := 10;
Memo.Text := qryPrn.Fields[i + 3].FieldName;
Memo.Frame.Typ := [ftTop, ftBottom, ftRight];
Memo.SetBounds(220 + (i - 1) * DataWidth, Band.Height - DataHeight, DataWidth, DataHeight);
Memo.HAlign := haCenter;
Memo.VAlign := vaCenter;
end;
6.画数据集
DataBand := TfrxMasterData.Create(Page);
DataBand.CreateUniqueName;
DataBand.DataSet := frxDBDataset1;
DataBand.Top := 200;
DataBand.Height := DataHeight;
Memo1 := TfrxMemoView.Create(DataBand);
with Memo1 do
begin
CreateUniqueName;
ParentFont := False;
SetBounds(30, 0, 90, DataHeight);
VAlign := vaCenter;
HAlign := haLeft;
Font.Name := '宋体';
Font.Size := 10;
DataSet := frxDBDataset1;
DataField := 'locus';
Frame.Typ := [ftRight, ftBottom, ftLeft];
end;
Memo1 := TfrxMemoView.Create(DataBand);
with Memo1 do
begin
CreateUniqueName;
ParentFont := False;
SetBounds(120, 0, 100, DataHeight);
VAlign := vaCenter;
HAlign := haRight;
Font.Name := '宋体';
Font.Size := 10;
DataSet := frxDBDataset1;
DataField := 'TotalMoney';
Frame.Typ := [ftRight, ftBottom]; //加上右边和底部的边框
end;
for i := 1 to qryPrn.FieldCount - 4 do
begin
Memo1 := TfrxMemoView.Create(DataBand);
Memo1.CreateUniqueName;
Memo1.ParentFont := False;
Memo1.SetBounds(220 + (i - 1) * DataWidth, 0, DataWidth, DataHeight);
Memo1.DisplayFormat.DecimalSeparator := '.';
//Memo1.ExpressionDelimiters := ',';
//Memo1.DisplayFormat.FormatStr := '%2.2f'; 定义显示格式
//Memo1.DisplayFormat.Kind := fkNumeric;
Memo1.VAlign := vaCenter;
Memo1.HAlign := haRight;
Memo1.Font.Name := '宋体';
Memo1.Font.Size := 10;
Memo1.DataSet := frxDBDataset1;
Memo1.DataField := qryPrn.Fields[i + 3].FieldName;
Memo1.Frame.Typ := [ftRight, ftBottom];
end;
7.显示
frReport.PrepareReport();
frReport.ShowReport();
- 动态创建Fastreport
- 动态创建Fastreport
- 动态创建Fastreport
- 在FastReport中动态创建memo
- 动态创建Fastreport分以下几个步骤:
- 使用FastReport 3.0及以上版本创建动态报表的
- FastReport动态图表问题
- FastReport动态打印图片
- FastReport 动态加载图片
- 使用FastReport 3.0及以上版本创建动态报表的几个技巧
- 使用FastReport 3.0及以上版本创建动态报表的几个技巧(转)
- FastReport的动态页面设置
- Delphi FastReport动态加载图片
- Delphi FastReport动态加载图片
- FastReport
- FastReport
- FastReport
- FastReport studio 动态加载数据集 (zhuan)
- ListView 动态多重嵌套
- win32平台下互斥锁的实现
- Istream函数汇总及输入函数总结
- ppc 模拟器的安装、配置,以及一些常见问题及解决方法
- sql server系统表详细说明
- 动态创建Fastreport
- 整型
- linux下显示中文字体的几个必要条件
- IT人士必去的10个网站
- JQuery 中,使文本框获得焦点的方法
- 新手到来
- linux find命令详解
- 如何开启SQL Server 2008的远程联机
- 对日邮件头尾格式