请教高手、大侠,D7中水晶报表控件如何使用!!! 特向高手、大侠请教: D7里的水晶报表控件如何使用? 控件是9.2的,有没有相关的电子书,介绍一下啊,万分感激!!! 或给个例子,最好是功能全一点的,有注释. mail:[email protected] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 首先选择 1,project __ import type library 出现一个box 2,在box中 选择 crystal report x activex designer runtime library(x代表你的水晶报表是什么版本的,如8.5,那x就是8.5)3. 点击 Install 按纽 ,然后点击 Into New Package(这里会要求你输入一个路径(如:e:\borland\delphi7\Lib\cradrl.dpk) , 点击 ok就可以了。在确定框中点击 yes,在Delphi 的Activex中就增加了一个application对象。4.把application 拖放到form1中,project 自动生成如下代码:unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs;typeTForm1 = class(TForm)Application1: TApplication;procedure FormCreate(Sender: TObject);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);beginend;end.添加完apllication后,我们还要再增加一个报表浏览组件crystal Reports viewer control(crviewer.dll)步骤和上面是一样的:首先选择 1,project __ import type library 出现一个box2,在box中 选择 crystal reports viewer control3. 点击 Install 按纽 ,然后点击 Into New Package(这里会要求你输入一个路径(如:e:\borland\delphi6\Lib\crviewer.dpk) , 点击 ok就可以了。在确定框中点击 yes,在Delphi 的Activex中就增加了一个crviewer对象。4.把它添加到form15.在form1中增加一个Button现在就可以在button 的click 事件中写如下代码:procedure TForm1.Button1Click(Sender: TObject);varreport : IReport;begin/我们可以打开一个已经生成的报表,这是动态的,可以在报表制作的时/侯连接好数据库,当然也可以通过在delphi中调用LogonServer/setlogoninfo来动态连接数据库。report := Application1.OpenReport('c:\report1.rpt',crOpenReportByTempCopy);/*The CrOpenReportByDefault constant places a lock on the RPT file preventing it from being accessed by other applications or users. CrOpenReportByTempCopy is often preferred since it opens a temporary copy of the RPT file instead. */crViewer1.ReportSource := Report;crViewer1.ViewReport;end; 做好報表后,直接把水晶報表控件放在FORM上,然后在打印預覽的ONCLICK事件中寫代碼調用,例子(我用的是10.0)procedure TFormCustomer.BitBtn6Click(Sender: TObject);begin Crpe1.Clear; //報表路徑 Crpe1.reportname:=Extractfilepath(Application.ExeName)+'RPT\customer.rpt'; //數据庫連接 Crpe1.Connect.ServerName :='data_server' ; Crpe1.Connect.UserID :='SA'; Crpe1.Connect.Password :='SA'; Crpe1.Connect.DatabaseName :='SA'; Crpe1.selection.formula.clear; Crpe1.selection.Clear ; Crpe1.selection.formula.add(' {custitem.seqno}<>9999'); //條件選擇 if RadioGroup1.ItemIndex =0 then crpe1.selection.formula.add(' and Mid ({Custitem.itemcode},4 ,1 )="C"') else crpe1.selection.formula.add(' and Mid ({Custitem.itemcode},4 ,1 )="F"') ; Crpe1.execute;end; to wulingyigu(武陵遗孤) : 怎没看到用crpe1,和CrpeDS1?to yoyoxu():Crpe1.selection.formula.clear; Crpe1.selection.Clear ; Crpe1.selection.formula.add(' {custitem.seqno}<>9999'); //條件選擇 if RadioGroup1.ItemIndex =0 then crpe1.selection.formula.add(' and Mid ({Custitem.itemcode},4 ,1 )="C"') else crpe1.selection.formula.add(' and Mid ({Custitem.itemcode},4 ,1 )="F"') ; Crpe1.execute; 没看懂,能否解释一下?谢谢!!! 个位虾哥,帮我解决图标问题好不 很急的问题!请大家来看看 女朋友考试结果出来,该怎么奖励她好呢?或者送她什么东西好呢?请大家帮忙 创建数据库 TClientSocket 的实现 关于程序的版本号的问题? 请高手指点关于中delphi5控件中调用excel的问题 向大侠请教DLL的问题!在线等待回复!急~~~!!!!! 用adoquery將一個數據表中的記錄移到另一個數據表中﹐該怎樣實現﹖ Delphi 如何屏蔽JPEG Error 错误 一个关于DELPHI的基础问题(关于工程文件打开出错) 各位朋友,不知能否帮助小生推荐下?感激不尽
表你的水晶报表是什么版本的,如8.5,那x就是8.5)
3. 点击 Install 按纽 ,然后点击 Into New Package(这里会要求你输入一
个路径(如:e:\borland\delphi7\Lib\cradrl.dpk) , 点击 ok就可以了。在确定框中
点击 yes,在Delphi 的Activex中就增加了一个application对象。
4.把application 拖放到form1中,project 自动生成如下代码:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
Application1: TApplication;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
beginend;end.添加完apllication后,我们还要再增加一个报表浏览组件crystal Reports viewer co
ntrol(crviewer.dll)
步骤和上面是一样的:
首先选择 1,project __ import type library 出现一个box2,在box中 选择 crystal reports viewer control
3. 点击 Install 按纽 ,然后点击 Into New Package(这里会要求你输入一
个路径(如:e:\borland\delphi6\Lib\crviewer.dpk) , 点击 ok就可以了。在确定框
中点击 yes,在
Delphi 的Activex中就增加了一个crviewer对象。
4.把它添加到form1
5.在form1中增加一个Button
现在就可以在button 的click 事件中写如下代码:procedure TForm1.Button1Click(Sender: TObject);
var
report : IReport;
begin
/我们可以打开一个已经生成的报表,这是动态的,可以在报表制作的时
/侯连接好数据库,当然也可以通过在delphi中调用LogonServer
/setlogoninfo来动态连接数据库。
report := Application1.OpenReport('c:\report1.rpt',
crOpenReportByTempCopy);/*The CrOpenReportByDefault constant places a lock o
n the RPT file
preventing it from being accessed by other applications or users.
CrOpenReportByTempCopy is often preferred since it opens a temporary
copy of the RPT file instead. */crViewer1.ReportSource := Report;
crViewer1.ViewReport;
end;
procedure TFormCustomer.BitBtn6Click(Sender: TObject);
begin
Crpe1.Clear;
//報表路徑
Crpe1.reportname:=Extractfilepath(Application.ExeName)+'RPT\customer.rpt';
//數据庫連接
Crpe1.Connect.ServerName :='data_server' ;
Crpe1.Connect.UserID :='SA';
Crpe1.Connect.Password :='SA';
Crpe1.Connect.DatabaseName :='SA';
Crpe1.selection.formula.clear;
Crpe1.selection.Clear ;
Crpe1.selection.formula.add(' {custitem.seqno}<>9999');
//條件選擇
if RadioGroup1.ItemIndex =0 then
crpe1.selection.formula.add(' and Mid ({Custitem.itemcode},4 ,1 )="C"')
else
crpe1.selection.formula.add(' and Mid ({Custitem.itemcode},4 ,1 )="F"') ;
Crpe1.execute;
end;
怎没看到用crpe1,和CrpeDS1?
to yoyoxu():
Crpe1.selection.formula.clear;
Crpe1.selection.Clear ;
Crpe1.selection.formula.add(' {custitem.seqno}<>9999');
//條件選擇
if RadioGroup1.ItemIndex =0 then
crpe1.selection.formula.add(' and Mid ({Custitem.itemcode},4 ,1 )="C"')
else
crpe1.selection.formula.add(' and Mid ({Custitem.itemcode},4 ,1 )="F"') ;
Crpe1.execute;
没看懂,能否解释一下?谢谢!!!