分享
 
 
 

Delphi 7 中使用RAVE报表(四)

王朝delphi·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

Delphi 7 中使用RAVE报表(四)

——利用程序设计一张报表

上一篇向大家介绍了建立一张简单报表的过程。这篇文章向大家介绍rave报表代码编程实例。窗体上放置组件:RvSystem, Button即可。

具体代码如下:

##################################################################################

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, RpDefine, RpBase, RpSystem;

type

TForm1 = class(TForm)

RvSystem1: TRvSystem;

Button1: TButton;

procedure RvSystem1Print(Sender: TObject);

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.RvSystem1Print(Sender: TObject);

var

I1: integer;

S1: string[20];

S2: string[20];

Bitmap: TBitmap;

PolyLineArr: array[1..6] of TPoint;

begin

with Sender as TBaseReport do begin

{ 打印表头和表尾 }

SectionTop := 0.75;//顶端

SetFont('黑体',26);//设置字体

Underline := true;//下划线

Home;

YPos := 1.0;

FontRotation :=20;//旋转角度

PrintCenter('我的报表',PageWidth / 2);

SetFont('宋体',10);

SectionBottom := 10.75;

PrintFooter('第' + IntToStr(CurrentPage) + '页',pjLeft);//页码

PrintFooter('日期: '+DateToStr(Date)+' ',pjRight);//日期

SectionBottom := 10.5;

YPos := 1.5;

SetFont('宋体',12);

SetTopOfPage;

Home;

{ 打印列标题 }

ClearTabs;

SetPen(clBlack,psSolid,1,pmCopy); { 设置画笔为一个点宽 }

SetTab(0.5,pjCenter,3.5,0,BOXLINEALL,0);

SetTab(NA,pjCenter,1.0,0,BOXLINEALL,0);

SetTab(NA,pjCenter,1.5,0,BOXLINEALL,0);

SetTab(NA,pjCenter,1.5,0,BOXLINEALL,0);

Bold := true;

Tab(-2,NA,-2,-2,NA); { 画出具有粗边框的表格 }

Print('Name');

Tab(NA,NA,-2,-2,NA);

Print('Number');

Tab(NA,NA,-2,-2,NA);

Print('Amount 1');

Tab(NA,-2,-2,-2,NA);

Println('Amount 2');

Bold := false;

{ 打印具有边框的数据 }

ClearTabs;

SetTab(0.5,pjLeft,3.5,2,BOXLINEALL,0);

SetTab(NA,pjCenter,1.0,2,BOXLINEALL,0);

SetTab(NA,pjRight,1.5,2,BOXLINEALL,10);

SetTab(NA,pjRight,1.5,2,BOXLINEALL,0);

for I1 := 1 to 10 do begin

Str(I1 * 1.23:2:2,S1);

Str(I1 * 98.76:2:2,S2);

Print(#9'LastName' + IntToStr(I1) + ', ');

SetFont('Times New Roman',8);

Print('FirstName M.');

SetFont('Times New Roman',12);

Println(#9 + IntToStr(I1) + #9'$' + S1 + #9'$' + S2);

end; { for }

{ 打印具有阴影的数据 }

ClearTabs;

SetTab(0.5,pjLeft,3.5,2,BOXLINENONE,0);

SetTab(NA,pjCenter,1.0,2,BOXLINENONE,0);

SetTab(NA,pjRight,1.5,2,BOXLINENONE,0);

SetTab(NA,pjRight,1.5,2,BOXLINENONE,0);

for I1 := 11 to 20 do begin

If Odd(I1) then begin

TabShade := 0;

end else begin

TabShade := 15;

end; { else }

Str(I1 * 1.23:2:2,S1);

Str(I1 * 98.76:2:2,S2);

Print(#9'LastName' + IntToStr(I1) + ', ');

SetFont('Times New Roman',8);

Print('FirstName M.');

SetFont('Times New Roman',12);

Println(#9 + IntToStr(I1) + #9'$' + S1 + #9'$' + S2);

end; { for }

ClearTabs;

{ 分栏报表 }

ClearTabs;

SetTopOfPage;

SectionBottom := 8.0;

Home;

SetFont('宋体',12);

Bold := true;

Underline := true;

Print(' 分栏报表 (LinesLeft/ColumnLinesLeft/LineNum/ColumnNum)');

SetTopOfPage; { Set top of page to current YPos }

Bold := false;

Underline := false;

Italic := false;

Home; { Goto home position }

SetColumns(4,0.5); { Create 4 columns with 0.5" between each }

while ColumnLinesLeft > 0 do begin

Println(IntToStr(LinesLeft) + '/' + IntToStr(ColumnLinesLeft) + '/' +

IntToStr(LineNum) + '/' + IntToStr(ColumnNum));

end; { while }

{ 具有边框的分栏报表 }

ClearTabs;

SetTopOfPage;

SectionBottom := 10.5;

Home;

SetFont('Times New Roman',12);

Bold := true;

Italic := true;

Print('Boxed Columns');

SetTopOfPage; { Set top of page to current YPos }

Bold := false;

Italic := false;

Home; { Goto home position }

ClearTabs;

SetPen(clBlack,psSolid,1,pmCopy);

SetTab(0.5,pjCenter,0.375,0,BOXLINEALL,0);

SetTab(NA,pjCenter,0.375,0,BOXLINEALL,0);

SetTab(NA,pjCenter,0.375,0,BOXLINEALL,0);

SetTab(NA,pjCenter,0.375,0,BOXLINEALL,0);

SetColumns(4,0.5); { Create 4 columns with 0.5" between each }

while ColumnLinesLeft > 0 do begin

if LineNum = 1 then begin

TabShade := 15;

Println(#9'LL'#9'CLL'#9'L#'#9'C#'); { 打印标题栏 }

end else begin

TabShade := 0;

Println(#9 + IntToStr(LinesLeft) + #9 + IntToStr(ColumnLinesLeft) +

#9 + IntToStr(LineNum) + #9 + IntToStr(ColumnNum));

end; { else }

end; { while }

SetColumns(1,0);

{ 在指定位置绘出文本 }

NewPage;

OriginX := 0.0; { Set origin to normal }

OriginY := 0.0;

GotoXY(1.0,1.5);

Print('Text @ 1.0,1.5');

GotoXY(6.0,1.5);

Println('Text @ 6.0,1.5');

GotoXY(2.0,2.0);

Println('Text @ 2.0,2.0');

GotoXY(3.0,2.5);

Println('Text @ 3.0,2.5');

{*** 图形图片***}

NewPage;

ResetSection;

SetFont('Arial',24);

Underline := true;

Home;

PrintCenter('Graphics Page Demo',PageWidth / 2);

SetFont('Times New Roman',8);

SectionBottom := 10.75; { Temporarily move the section bottom down }

PrintFooter('Page ' + IntToStr(CurrentPage),pjLeft);

PrintFooter('Date 01/20/95',pjRight);

SectionBottom := 10.5; { Reset section bottom }

OriginX := 0.0;

OriginY := 0.5;

SetFont('Arial',10);

{ 半圆弧线}

SetPen(clBlack,psSolid,-2,pmCopy); { Set pen to black 2/100ths" wide }

YPos := 0.95;

PrintCenter('Arc() and Chord()',2.125);

Arc(1.125,1.0,3.125,3.0,3.125,2.0,0.0,0.0);

SetBrush(clBlack,bsClear,nil);

Chord(1.125,1.0,3.125,3.0,0.0,0.8,3.125,2.25);

{ 饼图 }

YPos := 0.95;

PrintCenter('Pie()',4.25);

SetPen(clBlack,psSolid,-2,pmCopy); { Set pen to black 2/100ths" wide }

SetBrush(clBlack,bsHorizontal,nil);

Pie(3.25,1.0,5.25,3.0,5.25,2.0,0.0,0.0);

SetBrush(clBlack,bsVertical,nil);

Pie(3.25,1.0,5.25,3.0,0.0,0.0,3.25,7.0);

SetBrush(clBlack,bsBDiagonal,nil);

Pie(3.25,1.0,5.25,3.0,3.25,7.0,5.25,2.0);

{ Bitmap 图片}

YPos := 3.4;

PrintCenter('PaintBitmapRect()',6.375);

Bitmap := TBitmap.Create;

Bitmap.LoadFromFile('RPDEMO.BMP');

PrintBitmapRect(5.375,3.5,7.375,5.5,Bitmap);

Bitmap.Free;

end;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

RvSystem1.Execute;//执行报表!

end;

end.

##################################################################################

好了,这样我们并没有使用rave,仅仅利用程序实现了报表。

(ps:转载请注明作者--高速公路上的鱼(cyq))

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有