FastReport的使用

一、使用TfrxReport 组件工作
1
、加载并存储报表
默认情况下,报表窗体同项目窗体构存储在同一个DFM文件中。多数情况下,无须再操作,因而你就不必采用特殊方法加载报表。如果你决定在文件中存储报表窗体或者是数据库的

Blob字段(他提供了非常大的弹性,你能够在非编译程序中修改),你必须使用“TfrxReport”提供的加载和存储方法。
function LoadFromFile(const FileName: String; ExceptionIfNotFound: Boolean = False): Boolean;
从一个给定名字文件中加载报表。如果第二个参数等于“True”并且文件没找到,那么他会触发一个异常。如果文件加载成功,他返回“True”

procedure LoadFromStream(Stream: TStream);
从流中加载报表。

procedure SaveToFile(const FileName: String);
用特殊名称文件存储报表。

procedure SaveToStream(Stream: TStream);
把报表存在流中。

例如:
Pascal:
frxReport1.LoadFromFile('c:/1.fr3');
frxReport1.SaveToFile('c:/2.fr3');

C++:
frxReport1->LoadFromFile("c://1.fr3");

frxReport1->SaveToFile("c://2.fr3");

2.设计报表
通过“TfrxReport.DesignReport”方法调用报表设计器。你必须在你的项目中包含报表设计器(必要条件是:要么使用“TfrxDesigner”组件,要么增加“frxDesgn”单元到uses

列表)
“DesigReport”
方法接受两个默认参数:
procedure DesignReport(Modal: Boolean = True; MDIChild: Boolean = False);
Modal
参数决定设计器是否被模态,MDIChild参数允许把设计器窗体作为一个MDI子窗体。

例如:
frxReport1.DesignReport;

3.运行报表
应用下面两个“TfrxReport”方法中的一个启动报表:
procedure ShowReport(ClearLastReport: Boolean = True);
启动报表并在预览窗体中显示。如果“ClearLastReport”参数等于“False”,报表将会增加先前的一个报表结果,否则清除前一个报表结构。

function PrepareReport(ClearLastReport: Boolean = True): Boolean;
启动报表,没有打开预览窗体,参数赋值与“ShowReport”方法同名。如果报表构造成功,他返回“True”

多数情况下,使用第一种方法更为方便一些。在报表被构造的同时,他会立刻显示一个预览窗体。

当需要增加另一个报表到前一个报表中的时候,“ClearLastReport”参数显得方便些。(此类技术用于批量报表打印)。

例如:
frxReport1.ShowReport;

 

4.预览报表
使用两种途径显示一个报表是可能的:两者都是调用“TfrxReport.ShowReport”方法(先前描述过了),或者使用“TfrxReport.ShowPreparedReport”方法来帮助实现。在第二

种情况下,报表构造没有被执行,但显示了一个完成的报表。也就是说,你要么在“PreparedReport”方法帮助下构造他,要么在构造前从文件中加载报表(查看加载/存储完

成的报表

例如:

Pascal:

if frxReport1.PrepareReport then
  frxReport1.ShowPreparedReport;

C++:

if(frxReport1->PrepareReport(true))
  frxReport1->ShowPreparedReport();

在这种情况下,报表构造器先被完成了,并显示在预览窗体中。构造一个庞大的报表可能要花费很多时间,那就是为什么使用“ShowReport”非等时同步方法会好于

“PrepareReport/ShowPreparedReport”方法。你可以通过“TfrxReport.PreviewOptions”属的缺省值设定预览参数值。(这句翻译的不够好,请参考原文)

原文参考:In this case, report construction is finished first, and after that it is displayed in the preview window. Construction of a large report can take

a lot of time, and that is why it is better to use the “ShowReport anisochronous” method, than the “PrepareReport/ShowPreparedReport” one. One can assign

preview settings by default via the “TfrxReport.PreviewOptions” property.[SPAN]5、打印报表
大多数情况下,你可以从预览窗体打印报表。要人工打印报表,你应该使用“TfrxReport.Print”方法,例如:

frxReport1.LoadFromFile(...);

frxReport1.PrepareReport;

frxReport1.Print;

同时,你可以在显示的打印对话框中设置打印参数,你也可以使用默认设定值。取消打印对话框,请参考“TfrxReport.PrintOptions”属性帮助

version 4.9 --------------- + added export headers/footers in ODF export + added ability to print/export transparent pictures (properties TfrxPictureView.Transparent and TfrxPictureView.TransparentColor) (PDF export doesn't supported) + added new "split to sheet" modes for TfrxXMLExport + added support of /PAGE tag in TfrxRichView, engine automatically break report pages when find /PAGE tag + added ability to hide Null values in TfrxChartView (TfrxChartView.IgnoreNulls = True) + added ability to set any custom page order for printing (i.e. 3,2,1,5,4 ) + [enterprise] added variables "AUTHLOGIN" and "AUTHGROUP" inside the any report + [enterprise] now any report file can be matched with any (one and more) group, these reports are accessible only in matched groups + [enterprise] now you can set-up cache delays for each report file (reports.xml) + [enterprise] added new properties editor for reports in Configuration utility (see Reports tab) + [enterprise] added property "Xml" - "SplitType" in server configuration - allow to select split on pages type between none/pages/printonprev/rowscount + [enterprise] added property "Xml" - "SplitRowsCount" in server configuration - sets the count of rows for "rowscount" split type + [enterprise] added property "Xml" - "Extension" in server configuration - allow select between ".xml" and ".xls" extension for output file + [enterprise] added property "Html" - "URLTarget" in server configuration - allow select the target attribute for report URLs + [enterprise] added property "ReportsFile" - path to file with reports to groups associations and cache delays + [enterprise] added property "ReportsListRenewTimeout" in server configuration + [enterprise] added property "ConfigRenewTimeout" in server configuration + [enterprise] added property "MimeType" for each output format in server configuration + [enterprise] added property "BrowserPrint" in server configuration - allow printing by browser, added new template nav_print_browser
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值