fastreport动态打印的问题(100分)(100分)

  • 主题发起人 主题发起人 zk123
  • 开始时间 开始时间
Z

zk123

Unregistered / Unconfirmed
GUEST, unregistred user!
一、动态从数据库中取出数据(编号,姓名),即动态给memo赋值。
二、根据编号调入图形(图形文件以编号值命名存放在当前目录)。
三、报表只一页,一页20条数据,打印完当前20条数据后,再将20条数据再赋值给报表对应位置进行打印。
请详细说明具体实现方法。
 
你先反报表控件摆好位置!!然后一个一个地给object给值,不就对了吗?
你为什么要动态打印?多事惹非
 
高手在哪里?
 
第一个问题:quickreport本身就是从数据库动态取数据
第二个问题:可以在数据库中加一个image类型的字段,然后在报表中加上一个报表控件qrimage
第三个问题:你可以设置纸张大小,使报表一次只显示20条记录,它会自动分页
 
哇,qb3000,人家说的是fastreport!
看看faq吧:
Q: In QR, I can write code like QRLabel1.Caption := 'Some text'. How can
Ido
this with FR?
A: FR objects is not a components (like in QR, RB). Use TfrReport.FindObject
method to find object by name:
var
t: TfrMemoView;
begin
t := TfrMemoView(frReport1.FindObject('Memo1'));
if t <> nil then
t.Memo.Text := 'FastReport';
end;
 
根据编号调入图形?
 
没人回答?
 
没人知道吗?
 
你应该详细看看它的faq。
 
to 老赵:能说清楚点吗?
 
看看这个。
unit cf_aj_jc_bb;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
cf_base, DBAction, ActnList, PrnDbgeh, OleCtnrs, DBOleContainer,
StdCtrls, ExtCtrls, FR_DSet, FR_DBSet, FR_Class, u_jgyh;
type
Tfm_aj_jc_bb = class(Tfm_base)
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
FrR_AJJC: TfrReport;
frDBDataSet1: TfrDBDataSet;
Panel2: TPanel;
RG_XZ: TRadioGroup;
GroupBox1: TGroupBox;
CB_MB: TComboBox;
procedure FormShow(Sender: TObject);
procedure RG_XZClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
FReportState: TReportState;
FDataSet: string;
{从fm_aj_jc_jjxtg的相应的Edit.Text中读取数据到报表}
procedure SetReportMemo(frPage: TfrPage;
ObjectName: string;
Edit: TEdit);
{判断FReportState, 生成Title的Memo}
procedure SetReportTitle(frPage: TfrPage;
TitleName: string);
{删除FastReport中相应的列}
procedure HideReportMemo(frPage: TfrPage;
Value: array of string);
procedure SetBandViewDataSet(frPage: TfrPage);
function FindEdit(EditName: string): TEdit;
public
{ Public declarations }
property RepotrState: TReportState read FReportState write FReportState;
property DataSet: string read FDataSet write FDataSet;
end;

var
fm_aj_jc_bb: Tfm_aj_jc_bb;
implementation
uses cd_ajgl, cf_aj_jc_jjxtg, cd_ISEEReport, cf_main;
{$R *.DFM}
procedure Tfm_aj_jc_bb.FormShow(Sender: TObject);
begin
inherited;
with dm_ajgl.cd_tmpdo
begin
Close;
CommandText := 'select reportname from gg_fastreport where reporttype is null';
Open;
while not Eofdo
begin
CB_MB.Items.Add(FieldByName('reportname').AsString);
Next;
end;
end;
end;

procedure Tfm_aj_jc_bb.RG_XZClick(Sender: TObject);
begin
inherited;
CB_MB.Enabled := RG_XZ.ItemIndex = 1;
end;

procedure Tfm_aj_jc_bb.Button1Click(Sender: TObject);
begin
inherited;
if CB_MB.Enabled then
begin
if CB_MB.Text = '' then
begin
ShowMessage('请选择自定义模板');
Exit;
end;
if dm_isee.LoadReport(CB_MB.Text, FrR_AJJC) then
FrR_AJJC.ShowReport
else
ShowMessage('该模板已经损坏或与安监模块不匹配');
end
else
begin
if dm_isee.LoadReport('安监检查模板', FrR_AJJC) then
begin
SetReportMemo(FrR_AJJC.Pages[0], 'MM_ZS', FindEdit('Edt_ZS'));
SetReportMemo(FrR_AJJC.Pages[0], 'MM_WSPS', FindEdit('Edt_WSPS'));
SetReportMemo(FrR_AJJC.Pages[0], 'MM_YSPS', FindEdit('Edt_YSPS'));
SetReportMemo(FrR_AJJC.Pages[0], 'MM_WCS', FindEdit('Edt_WCS'));
SetReportMemo(FrR_AJJC.Pages[0], 'MM_TDS', FindEdit('Edt_TDS'));
SetReportMemo(FrR_AJJC.Pages[0], 'MM_CBS', FindEdit('Edt_CBS'));
SetReportMemo(FrR_AJJC.Pages[0], 'MM_WCL', FindEdit('Edt_WCL'));
SetReportTitle(FrR_AJJC.Pages[0], 'MM_Title');
if FReportState <> rsTotal then
HideReportMemo(FrR_AJJC.Pages[0], ['MM_CDXZ', 'MM_DCDXZ']);
SetBandViewDataSet(FrR_AJJC.Pages[0]);
FrR_AJJC.ShowReport;
end
else
ShowMessage('该模板已经损坏或与安监模块不匹配');
end;
end;

procedure Tfm_aj_jc_bb.SetReportMemo(frPage: TfrPage;
ObjectName: string;
Edit: TEdit);
var
Tmp_frView: TfrView;
begin
try
Tmp_frView := frPage.FindObject(ObjectName);
if Tmp_frView is TfrMemoView then
begin
TfrMemoView(Tmp_frView).Memo.Clear;
if Edit <> nil then
TfrMemoView(Tmp_frView).Memo.Add(Edit.Text);
end;
except
end;
end;

procedure Tfm_aj_jc_bb.SetReportTitle(frPage: TfrPage;
TitleName: string);
var
Tmp_frView: TfrView;
i_jxh: Integer;
s_jmc: string;
begin
try
Tmp_frView := frPage.FindObject(TitleName);
if Tmp_frView is TfrMemoView then
begin
SelectAJSJ(fm_main.i_YHXH, i_jxh, s_jmc);
case FReportState of
rsTotal:
begin
TfrMemoView(Tmp_frView).Memo.Clear;
TfrMemoView(Tmp_frView).Memo.Add('[dm_ajgl.cd_jc_jjxtg."ND"]年' +
s_jmc + '检查流程传单统计');
end;
rsSeason:
begin
TfrMemoView(Tmp_frView).Memo.Clear;
TfrMemoView(Tmp_frView).Memo.Add('[dm_ajgl.cd_jc_jjxtg."ND"]年' +
s_jmc + '[IF([dm_ajgl.cd_jc_jjxtg."JJ"]= ''C'', ''春季'','+
' IF([dm_ajgl.cd_jc_jjxtg."JJ"]=''D'', ''冬季'','+
' IF([dm_ajgl.cd_jc_jjxtg."JJ"]=''T'', ''特殊'', ''全部'')))]' +
'检查流程传单统计');
end;
rsDepartment:
begin
TfrMemoView(Tmp_frView).Memo.Clear;
TfrMemoView(Tmp_frView).Memo.Add('[dm_ajgl.cd_jc_jjxtg."ND"]年' +
Tfm_aj_jc_jjxtg(fm_main.frm_current).Tree.Selected.Text +
'[IF([dm_ajgl.cd_jc_jjxtg."JJ"]= ''C'', ''春季'','+
' IF([dm_ajgl.cd_jc_jjxtg."JJ"]=''D'', ''冬季'','+
' IF([dm_ajgl.cd_jc_jjxtg."JJ"]=''T'', ''特殊'', ''全部'')))]' +
'检查流程传单统计');
end;
end;
end;
except
end;
end;

procedure Tfm_aj_jc_bb.HideReportMemo(frPage: TfrPage;
Value: array of string);
var
i_Counter: Integer;
Tmp_frView: TfrView;
begin
for i_Counter := Low(Value) to High(Value)do
begin
Tmp_frView := frPage.FindObject(Value[i_Counter]);
if Tmp_frView is TfrMemoView then
Tmp_frView.Visible := False;
end;
end;

procedure Tfm_aj_jc_bb.SetBandViewDataSet(frPage: TfrPage);
var
Tmp_frView: TfrView;
begin
Tmp_frView := frPage.FindObject('MainBand');
if Tmp_frView is TfrBandView then
TfrBandView(Tmp_frView).DataSet := DataSet;
end;

procedure Tfm_aj_jc_bb.Button2Click(Sender: TObject);
begin
inherited;
Close;
end;

function Tfm_aj_jc_bb.FindEdit(EditName: string): TEdit;
var
ComponentsCount: Integer;
begin
with fm_main.frm_currentdo
for ComponentsCount := 0 to ComponentCount - 1do
if(Components[ComponentsCount].Name = EditName)and
(Components[ComponentsCount] is TEdit)then
begin
Result := TEdit(Components[ComponentsCount]);
Exit;
end;
Result := nil;
end;

end.
 
留下mail,给一个例子你。
 
动态调入图像怎样实现?
yzk111@163.com
 
1。先用frCreateObject()创建你需要的frpictureview,(静态也可以了)
2。或者用Tfrpictureview(frPage.FindObject());
3.frpictureview.Loadfromstream.
 
用Tfrpictureview(frPage.FindObject('picture1'));
frpictureview.Loadfromstream. ???{具体怎样使用,请举例详细说明}
 
procedure TForm1.Button1Click(Sender: TObject);
var
FrView: TFrView;
OpenPictureDialog: TOpenPictureDialog;
begin
OpenPictureDialog := TOpenPictureDialog.Create(Self);
try
if OpenPictureDialog.Execute then
begin
FrView := FrReport.Pages[0].FindObject('Picture1');
if FrView is TFrPictureView then
(FrView as TFrPictureView).Picture.LoadFromFile(OpenPictureDialog.FileName);
end;
finally
OpenPictureDialog.Free;
end;
FrReport.ShowReport;
end;
 
TFrPictureView.LoadFromStream有Bug;
用TFrPictureView.Picture.Graphic.LoadFromStream or
TFrPictureView.Picture.Graphic.LoadFromFile可以,
TFrPictureView.Picture.Bitmap.LoadFromStream没有什么问题;
不过还是直接LoadFromFile简单些。。记得加分,呵呵。。
 
后退
顶部