调用FasterReport3.X做的DLL, frxDBDataSet无法动态获得字段列表给design报表窗口用 ( 积分: 50 )

  • 主题发起人 主题发起人 mc888
  • 开始时间 开始时间
M

mc888

Unregistered / Unconfirmed
GUEST, unregistred user!
本人用fasterReport3.0,把一个frxReport1,frxDBDataSet1封装成DLL,客户端传送报表模板名称及数据集给DLL,DLL完成报表显示全过程。。
代码如下: 但运行程序时,frxDBDataSet1下的字段列表为空,无法让用户动态设计报表。
恳请各位大哥请点。。。。感激!!!!!!!!!!!!!!!!!!!!!
Dll文件代码如下:
unit frmReport_unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, frxDesgn, ComCtrls, frxClass, frxPreview, ToolWin, frxDBSet,
frxADOComponents, ImgList, StdCtrls, Buttons, Menus, ExtCtrls,
frxExportTXT, frxExportXLS, frxExportPDF, DB;
type
TfrmReport = class(TForm)
StatusBar1: TStatusBar;
frxDesigner1: TfrxDesigner;
frxDbMaster: TfrxDBDataset;
ToolBar1: TToolBar;
ImageList1: TImageList;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ZoomPercent: TComboBox;
ToolButton7: TToolButton;
PageNo: TEdit;
ToolButton8: TToolButton;
ToolButton9: TToolButton;
ToolButton10: TToolButton;
ToolButton11: TToolButton;
ToolButton12: TToolButton;
ToolButton13: TToolButton;
PopupMenu1: TPopupMenu;
PDF1: TMenuItem;
EXCEL1: TMenuItem;
EXT1: TMenuItem;
Panel1: TPanel;
frxPreview1: TfrxPreview;
frxPDFExport1: TfrxPDFExport;
frxXLSExport1: TfrxXLSExport;
frxTXTExport1: TfrxTXTExport;
dsMaster: TDataSource;
frxReport1: TfrxReport;
ToolButton14: TToolButton;
procedure ToolButton8Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ToolButton14Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
frmReport: TfrmReport;
implementation
{$R *.dfm}
procedure TfrmReport.ToolButton8Click(Sender: TObject);
begin
self.Close;
end;

procedure TfrmReport.FormShow(Sender: TObject);
begin
// frxDbMaster.Initialize;
// frxDbMaster.GetFieldList(frxDBMAster.FieldAliases);
// frxReport1.DataSets.Add(frxDbMaster);
frxReport1.DataSets.Add(frxDbMaster);
frxDbMaster.GetFieldList(frxDBMAster.FieldAliases);
showMessage(inttostr(frxDBMAster.FieldAliases.Count));
frxReport1.DesignReport;
end;

procedure TfrmReport.ToolButton14Click(Sender: TObject);
begin
frxReport1.DesignReport;
end;

end.

客户端代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ADODB, DB, Provider, DBClient, frxClass, frxDBSet;
function openReport(Owner: TComponent;Master: TClientDataSet): boolean;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
ClientDataSet1: TClientDataSet;
DataSetProvider1: TDataSetProvider;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
ClientDataSet1CustomerID: TWideStringField;
ClientDataSet1CompanyName: TWideStringField;
ClientDataSet1ContactName: TWideStringField;
ClientDataSet1ContactTitle: TWideStringField;
ClientDataSet1Address: TWideStringField;
ClientDataSet1City: TWideStringField;
ClientDataSet1Region: TWideStringField;
ClientDataSet1PostalCode: TWideStringField;
ClientDataSet1Country: TWideStringField;
ClientDataSet1Phone: TWideStringField;
ClientDataSet1Fax: TWideStringField;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
function openReport(Owner: TComponent;Master: TClientDataSet): boolean;
external 'RepDll.dll';
procedure TForm1.Button1Click(Sender: TObject);
begin
if not clientDataSet1.Active then
clientDataSet1.Open;
openReport(self,clientDataSet1);
end;

end.
 
我一直用Grid++report,没用过Fasterreport,帮你顶一下吧
 
學習學習。。。
 
frxDbMaster,设置一下他的别名就ok了
 
如何设备frxdbMaster呢????不懂呀
 
這個問題。我一時回答不了。請高手吧。。
 
直接在用户操作界面加设计功能,同一窗体里面的可以调出设计字段。
dll的没有弄过
 
我也没有用过,帮你提前
 
我没做过DLL方式的,如果只是为了让用户可以自己设计或修改报表,只要调用designer就可以了。
 
后退
顶部