delphi
bbs/keylife/iblog_show.asp?xid=4650
--------------------------------------------------------------------------------
大富翁论坛
版权所有
KeyLife富翁笔记
作者: archonwang
标题: 在Delphi 中如何使用水晶报表
关键字:
分类: 个人专区
密级: 公开
(评分: , 回复: 2, 阅读: 3275) ??
首先选择
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\delphi6\Lib\cradrl.dpk) , 点击 ok就可以了。在确定框中点击 yes,在Delphi 的Activex中就增加了一个application对象。
4.把application 拖放到form1中,project 自动生成如下代码:
unit Unit1;
interface
uses
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);
begin
end;
end.
添加完apllication后,我们还要再增加一个报表浏览组件crystal Reports viewer control(crviewer.dll)
步骤和上面是一样的:
首先选择1,project -- import type library 出现一个box
2,在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 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;
/这样,我们就成功的调入了一个报表,实现了delphi对外部报表的引用
2003-12-2 11:09:00
发表评语???
2004-3-26 9:09:52 [李经通]Delphi 7 中如何使用 Crystal Report 9.2[编者注]:几天前上网时看到的一份极好
文档,在
此推荐给各位共同
学习和探讨。
2004-3-26 9:11:51 一、直接使用Crystal Report 9.2 动态库1、开发环境安装注意事项
开发环境要求安装 Delphi 7 和 Crystal Report 9.2,安装Crystal Report 9.2 的时候需要注意不推荐使用典型安装,因为在典型安装中很多功能都没有安装进去,例如数据访问和导出支持,最好使用自定义安装:
·初学者直接将其所有功能选中安装即可,保证不遗漏功能。
·高级使用者,可以针对自己的使用情况来选择。
·见下图,默认情况下没有选中字段定义和
常用的HTML导出,都是使用的时候才进行安装。
2004-3-26 9:12:53
2004-3-26 9:14:30 2、在Delphi 7 中引入Crystal Report Viewer 控件
·启动Delphi IDE,关闭所有文件。
·主菜单Project | Import Type Library… 打开导入类型库。
·选择Crystal Report Viewer Control 9(Version 9.2)。
·选中“Generate Compone