一个ACCESS数据库db1.mdb,里面有一张表userlist,
表里有两个字段:name,gold。其中name为字符型,gold为integer。
要求:用Rave制作一个查询"select * from userlist"报表,能预览所有的name和gold。请给出源代码。问题可能极简单,请不要笑。

解决方案 »

  1.   

    没有时间给你现成的源码。在BDN.borland.com上面有一个RAVE的系列英文文章,里面详细介绍了RAVE连接数据源的方法。
      

  2.   

    Delphi 7 中使用RAVE报表(四)这篇文章向大家介绍rave报表代码编程实例。窗体上放置组件:RvSystem, Button即可。具体代码如下:unit Unit1;interfaceuses  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.
      

  3.   


                                     Delphi7下的Rave组件介绍包括有RvProject、RvSystem、RvNDRWriter、RvCustomConnection、RvDataSetConnection、RvTableConnection、RvQueryConnection、RvRenderPreview、RvRenderPrinter、RvRenderPDF、RvRenderHTML、RvRenderRTF、RvRenderText这几个组件。lRvProject组件
    在使用rave报表中,这个组件是最为重要的一个,是使用频率最高的一个组件,开发人员可以通过这个报表完成报表的打印、文件的生成、输出,土过此事可以使用设计状态,也可以通过它来点用相应的报表设计器。属性:DLLFile:发行报表时需要的dll文件,在5.0以后用户不需要单独发行相应的动态链库文件了。Engine: 指定相应报表生成的目的地,一般的情况下,是RvSystem,也就是说它可以打印、打印预览、生成打印文件。当然也可以选择RvNDRWriter组件,那么报表输出的结果是RTF、HTML、PDF、TXT其中的一种。LoadDesigner: 允许用户调用报表设计器,如果它的值为true,那么最终用户就可以调用报表设计器;如果它的值为False,那么最终用户就没有权力调用报表设计器。ProjectFile:相应报表项目文件,指定详细目录路径。StoreRAV:要将报表文件嵌入到exe文件中,在这里就要填入相应的报表项目文件。主要方法:SelectReport方法:Function SelectReport(ReportName:String; FullName:Boolean):Boolean;ReportName是相应的报表名称,FullName则表示是否以报表的全程作为报表的名称。Execute方法:   打印选择的相应报表文件,报表时被SelectReport选择的。RvProject1.Execute;ExecuteReport方法:RvProject1.ExecuteReport(ReportName:String);   ReportName是相应的报表的名称。Open方法:RvProject1.Open; 打开相应的报表以共操作。Close方法:RvProject1.Close; 关闭一个报表的操作。l       RvSystem组件   打印或者预览报表时,进行打印参数设置的。使用时与RvProject结合。属性:DefaultDest:指定打印的方式。rdPreview:预览;rdFile:文件;rdPrinter:打印机。RulerType:相应的标尺单位。          rtNone:没有标尺;          rtHorizCm:横向标尺,单位为厘米;          rtVertCm:纵向标尺,单位为厘米;          rtBothCm:先是所有的标尺,单位为厘米;          rtHorizIn: 横向标尺,单位为英寸;          rtVertIn: 纵向标尺,单位为英寸;         rtBothIn:所有标尺,单位为英寸;SystemFiler:报表打印文件参数的设置。如果DefaultDest属性为rbFile,则需要设置这里的属性值。SystemOptions:所有报表输出设置属性。SystemPreview:报表预览参数的设置。如果DefaultDest属性为rdPreview,则需要设置这里的属性值。SystemPrinter:报表打印参数的设置。如果DefaultDest属性为rdPrinter ,则需要设置这里的属性值。SystemSetup:是对是否允许打印,是否允许打印机设置等参数的设置。TitlePreview:更改报表预览的窗体的名称,例如可以将Report Preview改为报表预览。TitleSetup:更改报表输出窗体的名称,例如可以将Output Options改为输出设置。TitleStatus:报表状态窗体名称,例如可以将Report Status改为报表状态。主要方法:OverridePreview方法,OverrideSetup方法,OverrideStatus方法:这三个方法可以对报表设置、打印设置、报表预览窗体进行覆盖,在后面会介绍如何通过这几个方法是窗体为中文。l       NDRWriter组件使用该组件实现自定义报表预览。l       RvDataSetConnection组件,RvTableConnection组件, RvQueryConnection组件使用这三个组件实现数据库的连接。l       RvRenderPDF组件, RvRenderHTML组件, RvRenderRTF组件,RvRenderText组件报表生成相应文件的组件,可让报表生成相应的pdf、html、rtf、text文件。但生成文件对中文不支持,会出现乱码。
      

  4.   

    以上朋友对rave的介绍也算比较详细了,但我的要求中提到了需要源代码,源代码中要有执行查询的过程吧……
      

  5.   

    Delphi7中使用Rave报表 
    http://www.delphifans.com/SoftView/SoftView_1904.html