用程序代码
设计报表 创建一窗体 Form1,unit 文件保存为 RaveReport.pas, 窗体上放置一个 RpSystem 控件和一个 Button,
程序代码如下,一个简单的报表就完成了。 unit RaveReport; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, RpRenderCanvas, RpRenderPreview, RpRender, RpRenderPDF, RpBase, RpSystem, StdCtrls, RpDefine, RpRave; type TForm1 = class(TForm) Button1: TButton; RvSystem1: TRvSystem; 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; //设定内容输出区域的顶部位置 These properties return or set the current section of the paper to be printed on. //Header 输出在 内容输出区域 的顶部 SetFont('宋体',10); PrintHeader('第' + IntToStr(CurrentPage) + '页',pjLeft); //页码 This method will print the string, Text, just below the current SectionTop justified by, Justify, between the current SectionLeft and SectionRight. PrintHeader('日期: '+DateToStr(Date)+' ',pjRight); //日期 This method will print the string, Text, just below the current SectionTop justified by, Justify, between the current SectionLeft and SectionRight. SectionBottom := 10.75; //设定内容输出区域的底部位置 These properties return or set the current section of the paper to be printed on. //Footer 输出在 内容输出区域 的底部 SetFont('宋体',10); PrintFooter('第' + IntToStr(CurrentPage) + '页',pjLeft); //页码 This method will print the string, Text, just above the current SectionBottom justified by, Justify, between the current SectionLeft and SectionRight. PrintFooter('日期: '+DateToStr(Date)+' ',pjRight); //日期 This method will print the string, Text, just above the current SectionBottom justified by, Justify, between the current SectionLeft and SectionRight.
//输出
报告的题目 YPos := 1.0; //垂直方向的位置(从页顶向下的绝对位置, 不受内容输出区域范 围的限制,单位缺省为 Inch) This property sets or returns the horizontal text cursor position. SetFont('黑体',26); //设置字体 Underline := true; //下划线 FontRotation :=20; //旋转文字排列走向的角度(按逆时针方向) PrintCenter('我的报表',PageWidth / 2); //在(PageWidth/2)位置居中输出字符串(字符串的 水平中心与(PageWidth/2)位置相重合) //文字的下基线作为垂直方向的定位点 SetFont('宋体',10); Underline := False; FontRotation :=0;
//--------重置内容区的底部位置 SectionTop := 1.5; //顶端开始于 0.75Inch SectionBottom := 10.5; //设定内容输出区域的底部位置 properties r
eturn or set the current section of the paper to be printed on. Home; //把文本光标移动到内容输出区域第 1 行的行首 method will move the text cursor to the beginning of line 1. // 打印列标题 ClearTabs;
These This
SetPen(clBlack,psSolid,1,pmCopy); //设置画笔为一个点宽 SetTab(0.5,pjCenter,3.5,0,BOXLINEALL,0); //BOXLINEALL 表格中各个 Cell 均有边框线 SetTab(NA, pjCenter,1.0,0,BOXLINEALL,0); SetTab(NA, pjCenter,1.5,0,BOXLINEALL,0); SetTab(NA, pjCenter,1.5,0,BOXLINEALL,0); SetFont('宋体',12); Bold := true; // 画