一个动态创建RAVE报表的例子程序
qxj 2003-10-23 10:33:50 今天看到一个不使用设计器创建RAVE的例子,就贴出来给那些用RAVE的兄弟作个参考
Unit Unit1;
Interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
DB, Dialogs, StdCtrls, Buttons, Math, ApoDSet,
RpBase, RpCon, RpConDS, RpDefine, RpDevice, RpRave, RpSystem,
RvClass, RvCsData, RvCsDraw, RvCsStd, RvCsRpt, RvData, RvDefine, RvDirectDataView, RvUtil;
Type
TForm1 = Class(TForm)
ApolloTable1: TApolloTable;
btnClose: TBitBtn;
btnReport: TButton;
DataSource1: TDataSource;
RvDataSetConnection1: TRvDataSetConnection;
RvProject1: TRvProject;
RvSystem1: TRvSystem;
Procedure btnReportClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
End;
Var
Form1: TForm1;
Implementation
{$R *.dfm}
Procedure TForm1.btnReportClick(Sender: TObject);
Var
MyBand, MyTitleBand: TRaveBand;
MyDataBand: TRaveDataBand;
MyDataCnx: TRaveDataConnection;
MyDataText: TRaveDataText;
MyDataView: TRaveDataView;
MyLine: TRaveHLine;
MyPage: TRavePage;
MyRegion: TRaveRegion;
MyText: TRaveText;
nMarginBottom, nMarginLeft, nMarginRight, nMarginTop: Double;
// I1: integer;
Begin
// Select the project file
// RvProject1.ProjectFile := 'Project1.rav';
// RvProject1.Open;
// OR
RvProject1.New;
// 1 - use a blank page "Page 1 in Report 1" ======================
MyPage := RvProject1.ProjMan.FindRaveComponent('Report1.Page1', Nil) As TRavePage;
MyPage.WasteFit := True;
// Set all margins to 搘aste?or 0.5 which ever is greater
nMarginBottom := MaxValue([RpDev.Waste.Bottom / RpDev.YDPI, 0.5]);
nMarginLeft := MaxValue([RpDev.Waste.Left / RpDev.XDPI, 0.5]);
nMarginRight := MaxValue([RpDev.Waste.Right / RpDev.XDPI, 0.5]);
nMarginTop := MaxValue([RpDev.Waste.Top / RpDev.YDPI, 0.5]);
// If you need to Delete all components on the page
//for I1 := MyPage.ComponentCount - 1 downto 0 do begin
// MyPage.Components[I1].Free;
//end;
.