通用FASTREPORT打印模块及接口方法

untFastReport.dfm文件:

object frmFastReport: TfrmFastReport
OldCreateOrder = False
Height = 405
Width = 550
object report: TfrxReport
Version = '4.15.10'
DotMatrixReport = False
IniFile = '\Software\Fast Reports'
PreviewOptions.Buttons = [pbPrint, pbLoad, pbSave, pbExport, pbZoom, pbFind, pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator, pbExportQuick]
PreviewOptions.Zoom = 1.000000000000000000
PrintOptions.Printer = #39044#35774
PrintOptions.PrintOnSheet = 0
ReportOptions.CreateDate = 41954.598210555600000000
ReportOptions.LastChange = 41954.640443842600000000
ScriptLanguage = 'PascalScript'
ScriptText.Strings = (
''
'begin'
''
'end.')
Left = 16
Top = 16
Datasets = <
item
DataSet = DB
DataSetName = 'db'
end
item
DataSet = DB2
DataSetName = 'db2'
end>
Variables = <>
Style = <>
object Data: TfrxDataPage
Height = 1000.000000000000000000
Width = 1000.000000000000000000
end
object Page1: TfrxReportPage
PaperWidth = 210.000000000000000000
PaperHeight = 297.000000000000000000
PaperSize = 9
LeftMargin = 10.000000000000000000
RightMargin = 10.000000000000000000
TopMargin = 10.000000000000000000
BottomMargin = 10.000000000000000000
object ReportTitle1: TfrxReportTitle
Height = 132.283550000000000000
Top = 18.897650000000000000
Width = 718.110700000000000000
object Memo2: TfrxMemoView
Left = 306.141930000000000000
Top = 3.779530000000000000
Width = 94.488250000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = [fsBold]
HAlign = haCenter
Memo.UTF8W = (
#37319#36141#30003#35831#21333)
ParentFont = False
end
object Memo3: TfrxMemoView
Left = 3.779530000000000000
Top = 26.456710000000000000
Width = 71.811070000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Memo.UTF8W = (
#30003#35831#37096#38376#65306)
ParentFont = False
end
object Memo4: TfrxMemoView
Left = 79.370130000000000000
Top = 26.456710000000000000
Width = 219.212740000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
ParentFont = False
end
object Memo5: TfrxMemoView
Left = 321.260050000000000000
Top = 26.456710000000000000
Width = 75.590600000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Memo.UTF8W = (
#21040#36135#26085#26399#65306)
ParentFont = False
end
object Memo6: TfrxMemoView
Left = 404.409710000000000000
Top = 26.456710000000000000
Width = 294.803340000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
ParentFont = False
end
object Memo7: TfrxMemoView
Left = 3.779530000000000000
Top = 49.133890000000000000
Width = 71.811070000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Memo.UTF8W = (
#30003#35831#20154#65306)
ParentFont = False
end
object Memo8: TfrxMemoView
Left = 79.370130000000000000
Top = 49.133890000000000000
Width = 219.212740000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
ParentFont = False
end
object Memo9: TfrxMemoView
Left = 321.260050000000000000
Top = 49.133890000000000000
Width = 75.590600000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Memo.UTF8W = (
#30003#35831#26085#26399#65306)
ParentFont = False
end
object Memo10: TfrxMemoView
Left = 404.409710000000000000
Top = 49.133890000000000000
Width = 294.803340000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
ParentFont = False
end
object Memo11: TfrxMemoView
Top = 71.811070000000000000
Width = 75.590600000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Memo.UTF8W = (
#22791#27880#65306)
ParentFont = False
end
object Memo12: TfrxMemoView
Left = 79.370130000000000000
Top = 71.811070000000000000
Width = 619.842920000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
ParentFont = False
end
object Memo13: TfrxMemoView
Left = 3.779530000000000000
Top = 113.385900000000000000
Width = 34.015770000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Frame.Typ = [ftLeft, ftRight, ftTop, ftBottom]
Memo.UTF8W = (
#24207#21495)
ParentFont = False
end
object Memo14: TfrxMemoView
Left = 37.795300000000000000
Top = 113.385900000000000000
Width = 60.472480000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Frame.Typ = [ftLeft, ftRight, ftTop, ftBottom]
Memo.UTF8W = (
#29289#26009#32534#21495)
ParentFont = False
end
object Memo15: TfrxMemoView
Left = 98.267780000000000000
Top = 113.385900000000000000
Width = 173.858380000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Frame.Typ = [ftLeft, ftRight, ftTop, ftBottom]
Memo.UTF8W = (
#29289#26009#21517#31216)
ParentFont = False
end
object Memo16: TfrxMemoView
Left = 271.551330000000000000
Top = 113.385900000000000000
Width = 60.472480000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Frame.Typ = [ftLeft, ftRight, ftTop, ftBottom]
Memo.UTF8W = (
#35745#37327#21333#20301)
ParentFont = False
end
object Memo17: TfrxMemoView
Left = 331.582870000000000000
Top = 113.385900000000000000
Width = 94.488250000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Frame.Typ = [ftLeft, ftRight, ftTop, ftBottom]
Memo.UTF8W = (
#35268#27169#22411#21495)
ParentFont = False
end
object Memo18: TfrxMemoView
Left = 426.071120000000000000
Top = 113.385900000000000000
Width = 64.252010000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Frame.Typ = [ftLeft, ftRight, ftTop, ftBottom]
Memo.UTF8W = (
#30003#35831#25968#37327)
ParentFont = False
end
object Memo19: TfrxMemoView
Left = 489.882190000000000000
Top = 113.385900000000000000
Width = 188.976500000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Frame.Typ = [ftLeft, ftRight, ftTop, ftBottom]
Memo.UTF8W = (
#22791#27880)
ParentFont = False
end
end
object MasterData1: TfrxMasterData
Height = 18.897637800000000000
Top = 211.653680000000000000
Width = 718.110700000000000000
DataSet = DB2
DataSetName = 'db2'
RowCount = 0
object Memo20: TfrxMemoView
Left = 3.779530000000000000
Width = 34.015770000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = [fsBold]
HAlign = haCenter
Memo.UTF8W = (
'[db2."SeqNo"]')
ParentFont = False
end
object Memo21: TfrxMemoView
Left = 37.795300000000000000
Top = 0.779530000000000000
Width = 60.472480000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = [fsBold]
HAlign = haCenter
ParentFont = False
end
object Memo22: TfrxMemoView
Left = 98.267780000000000000
Width = 173.858380000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = [fsBold]
HAlign = haCenter
ParentFont = False
end
object Memo23: TfrxMemoView
Left = 272.126160000000000000
Width = 60.472480000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = [fsBold]
HAlign = haCenter
ParentFont = False
end
object Memo24: TfrxMemoView
Left = 333.378170000000000000
Width = 94.488188980000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = [fsBold]
HAlign = haCenter
ParentFont = False
end
object Memo25: TfrxMemoView
Left = 428.086890000000000000
Width = 64.251968500000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = [fsBold]
HAlign = haCenter
ParentFont = False
end
object Memo26: TfrxMemoView
Left = 491.338900000000000000
Width = 188.976500000000000000
Height = 18.897650000000000000
ShowHint = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = [fsBold]
HAlign = haCenter
ParentFont = False
end
end
object PageFooter1: TfrxPageFooter
Height = 22.677180000000000000
Top = 291.023810000000000000
Width = 718.110700000000000000
object Memo1: TfrxMemoView
Left = 642.520100000000000000
Width = 75.590600000000000000
Height = 18.897650000000000000
ShowHint = False
HAlign = haRight
Memo.UTF8W = (
'[Page#]')
end
end
end
end
object DB: TfrxDBDataset
UserName = 'db'
CloseDataSource = False
DataSet = cds
BCDToCurrency = False
Left = 64
Top = 8
end
object ExpHtml: TfrxHTMLExport
ShowDialog = False
UseFileCache = True
ShowProgress = False
OverwritePrompt = False
DataOnly = False
FixedWidth = True
Background = False
Centered = False
EmptyLines = True
Print = False
PictureType = gpPNG
Left = 224
Top = 224
end
object cds: TClientDataSet
Aggregates = <>
Params = <>
Left = 112
Top = 8
end
object DB2: TfrxDBDataset
UserName = 'db2'
CloseDataSource = False
DataSet = cds2
BCDToCurrency = False
Left = 168
Top = 8
end
object cds2: TClientDataSet
Aggregates = <>
Params = <>
Left = 216
Top = 16
end
object frxXLSExport1: TfrxXLSExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
ExportEMF = True
AsText = False
Background = True
FastExport = True
PageBreaks = True
EmptyLines = True
SuppressPageHeadersFooters = False
Left = 152
Top = 224
end
object frxXMLExport1: TfrxXMLExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
Background = True
Creator = 'FastReport'
EmptyLines = True
SuppressPageHeadersFooters = False
RowsCount = 0
Split = ssNotSplit
Left = 296
Top = 224
end
object frxMailExport1: TfrxMailExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
ShowExportDialog = True
SmtpPort = 25
UseIniFile = True
TimeOut = 60
ConfurmReading = False
UseMAPI = False
Left = 400
Top = 280
end
object frxPDFExport1: TfrxPDFExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
PrintOptimized = False
Outline = False
Background = False
HTMLTags = True
Quality = 95
Author = 'FastReport'
Subject = 'FastReport PDF export'
ProtectionFlags = [ePrint, eModify, eCopy, eAnnot]
HideToolbar = False
HideMenubar = False
HideWindowUI = False
FitWindow = False
CenterWindow = False
PrintScaling = False
Left = 312
Top = 280
end
object frxRTFExport1: TfrxRTFExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
PictureType = gpPNG
Wysiwyg = True
Creator = 'FastReport'
SuppressPageHeadersFooters = False
HeaderFooterMode = hfText
AutoSize = False
Left = 232
Top = 280
end
object frxCSVExport1: TfrxCSVExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
Separator = ','
OEMCodepage = False
NoSysSymbols = True
ForcedQuotes = False
Left = 368
Top = 224
end
object frxBMPExport1: TfrxBMPExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
Left = 136
Top = 272
end
object frxJPEGExport1: TfrxJPEGExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
Left = 448
Top = 224
end
object frxGIFExport1: TfrxGIFExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
Left = 40
Top = 272
end
object frxSimpleTextExport1: TfrxSimpleTextExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
Frames = False
EmptyLines = False
OEMCodepage = False
DeleteEmptyColumns = True
Left = 48
Top = 216
end
object frxBarCodeObject1: TfrxBarCodeObject
Left = 40
Top = 104
end
object frxOLEObject1: TfrxOLEObject
Left = 128
Top = 104
end
object frxChartObject1: TfrxChartObject
Left = 216
Top = 104
end
object frxRichObject1: TfrxRichObject
Left = 288
Top = 104
end
object frxCrossObject1: TfrxCrossObject
Left = 368
Top = 104
end
object frxCheckBoxObject1: TfrxCheckBoxObject
Left = 464
Top = 104
end
object frxGradientObject1: TfrxGradientObject
Left = 40
Top = 152
end
end

 

untFastReport.pas文件:

{ *******************************************************
单元功用:
单元设计:陈新光
设计日期:2014-08-19
单元修改:
修改日期:
******************************************************* }

unit untFastReport;

interface

uses
System.SysUtils, System.Classes, Data.DB,
Datasnap.DBClient, frxClass, frxExportHTML, frxDBSet, frxchart,
frxExportXLS, frxExportMail, frxExportXML, frxExportPDF, frxExportText,
frxExportImage, frxExportCSV, frxExportRTF, Vcl.Dialogs, System.Variants,
frxBarcode, frxOLE, frxGradient, frxChBox, frxCross, frxRich;

type
TfrmFastReport = class(TDataModule)
report: TfrxReport;
DB: TfrxDBDataset;
ExpHtml: TfrxHTMLExport;
cds: TClientDataSet;
DB2: TfrxDBDataset;
cds2: TClientDataSet;
frxXLSExport1: TfrxXLSExport;
frxXMLExport1: TfrxXMLExport;
frxMailExport1: TfrxMailExport;
frxPDFExport1: TfrxPDFExport;
frxRTFExport1: TfrxRTFExport;
frxCSVExport1: TfrxCSVExport;
frxBMPExport1: TfrxBMPExport;
frxJPEGExport1: TfrxJPEGExport;
frxGIFExport1: TfrxGIFExport;
frxSimpleTextExport1: TfrxSimpleTextExport;
frxBarCodeObject1: TfrxBarCodeObject;
frxOLEObject1: TfrxOLEObject;
frxChartObject1: TfrxChartObject;
frxRichObject1: TfrxRichObject;
frxCrossObject1: TfrxCrossObject;
frxCheckBoxObject1: TfrxCheckBoxObject;
frxGradientObject1: TfrxGradientObject;
private
{ Private declarations }
public
{ Public declarations }
// 预备打印
procedure Prepare(const ReportModal: string;aCDS, aCDS2: TClientDataSet);
// 设置指定对象的值
procedure SetObjValue(const objName:string; value:Variant);
// 预览报表
procedure Preview;
// 直接打印报表
procedure Print;
// 设计报表
procedure DesignReport(const ReportModal: string);
end;

var
frmFastReport: TfrmFastReport;

implementation

{ %CLASSGROUP 'Vcl.Controls.TControl' }

uses untCommon;

{$R *.dfm}
{ TfrmFastReport }

{ -------------------------------------------------------------------------------
过程名: TfrmFastReport.ShowReport 打印报表
作者: hnxxcxg
日期: 2014.08.19
参数: isShow: Boolean; 是否预览
const ReportModal: string; 报表模板文件
aCDS,aCDS2: TClientDataSet; 报表数据集
const varNames: string; 报表变量
varValues: Variant 报表变量值
返回值: 无
------------------------------------------------------------------------------- }
procedure TfrmFastReport.DesignReport(const ReportModal: string);
begin
if ReportModal <> '' then
begin
report.LoadFromFile(ReportModal);
report.DesignReport();
end;
end;

procedure TfrmFastReport.SetObjValue(const objName: string; value: Variant);
begin
TfrxMemoView(report.FindObject(objName)).Memo.Text:= VarToStr(value);
end;

procedure TfrmFastReport.Prepare(const ReportModal: string;
aCDS, aCDS2: TClientDataSet);
begin
if aCDS <> nil then
cds.Data := aCDS.Data;
if aCDS2 <> nil then
cds2.Data := aCDS2.Data;
report.LoadFromFile(ReportModal);
report.PrepareReport(true);
end;

procedure TfrmFastReport.Preview;
begin
report.ShowReport;
end;

procedure TfrmFastReport.Print;
begin
report.Print;
end;

end.

转载于:https://www.cnblogs.com/hnxxcxg/p/4105351.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值