procedure TZSYRJFXBfrm.PrnBitBtnClick(Sender: TObject); var i,j:integer; begin if not FileExists(ExtractFilePath(ParamStr(0))+'ZSYRJFXREP.frf') then begin messagebox(handle,'没找到报表模板,无法打印!!!','警告', mb_ok+mb_iconwarning); exit; end; ZHJLfrReport.LoadFromFile(ExtractFilePath(ParamStr(0))+'ZSYRJFXREP.frf'); frVariables.Variable['ZHJLWID']:=LogNM; frVariables.Variable['RQ']:=FormatDateTime('yyyy-mm-dd',date); if not (Repadoquery.Active) then Repadoquery.Open; if ADOQUERY1.RecordCount<=0 then begin if messagebox(handle,'没有记录,是否打印空表!!!','警告', mb_okcancel+mb_iconquestion)<>mrok then exit; end else begin try ADOQUERY1.First; while not ADOQUERY1.Eof do begin Repadoquery.Append; for j:=0 to ADOQUERY1.FieldCount-1 do begin if ADOQUERY1.Fields[j].FieldName='WQID' then Continue; if ADOQuery1.Fields[j].FieldName='GRAPH' then continue; if (ADOQuery1.Fields[j].FieldName<>'CYSJ' )and (ADOQuery1.Fields[j].FieldName<>'FXSJ') then begin Repadoquery.Fields[j].Value:=ADOQUERY1.Fields[j].Value; end else begin if(ADOQuery1.Fields[j].FieldName='CYSJ' ) then Repadoquery.fieldbyname('PICKDATE').Value:=ADOQuery1.fieldbyname('CYSJ').Value else Repadoquery.fieldbyname('ANADATE').Value:=ADOQuery1.fieldbyname('FXSJ').Value; end; end; Repadoquery.Post; ADOQUERY1.Next; end; except
end; //try end; i:=trunc((ZHJLfrReport.Pages[0].Prop['height']- integer(ZHJLfrReport.Pages[0].Prop['topmargin'])- integer(ZHJLfrReport.Pages[0].Prop['bottommargin'])- integer(ZHJLfrReport.FindObject('页头1').Prop['height'])- integer(ZHJLfrReport.FindObject('栏目脚1').Prop['height'])- integer(ZHJLfrReport.FindObject('页脚1').Prop['height'])) / integer(ZHJLfrReport.FindObject('主项数据1').Prop['height'])); if Repadoquery.RecordCount>0 then if (RepADOQuery.RecordCount mod i)=0 then i:=0 else i:=i-Repadoquery.RecordCount mod i; for j:=0 to i-1 do begin Repadoquery.Append; Repadoquery.FieldByName('WID').AsString:=''; Repadoquery.Post; end; if ZHJLfrReport.PrepareReport then ZHJLfrReport.ShowPreparedReport; Repadoquery.CancelBatch(arall); end; 这是代码 请大虾们帮我看看
var
i,j:integer;
begin
if not FileExists(ExtractFilePath(ParamStr(0))+'ZSYRJFXREP.frf') then
begin
messagebox(handle,'没找到报表模板,无法打印!!!','警告',
mb_ok+mb_iconwarning);
exit;
end; ZHJLfrReport.LoadFromFile(ExtractFilePath(ParamStr(0))+'ZSYRJFXREP.frf');
frVariables.Variable['ZHJLWID']:=LogNM;
frVariables.Variable['RQ']:=FormatDateTime('yyyy-mm-dd',date); if not (Repadoquery.Active) then Repadoquery.Open;
if ADOQUERY1.RecordCount<=0 then
begin
if messagebox(handle,'没有记录,是否打印空表!!!','警告',
mb_okcancel+mb_iconquestion)<>mrok then
exit;
end
else
begin
try
ADOQUERY1.First;
while not ADOQUERY1.Eof do
begin
Repadoquery.Append;
for j:=0 to ADOQUERY1.FieldCount-1 do
begin
if ADOQUERY1.Fields[j].FieldName='WQID' then Continue;
if ADOQuery1.Fields[j].FieldName='GRAPH' then continue;
if (ADOQuery1.Fields[j].FieldName<>'CYSJ' )and (ADOQuery1.Fields[j].FieldName<>'FXSJ') then
begin
Repadoquery.Fields[j].Value:=ADOQUERY1.Fields[j].Value;
end else
begin
if(ADOQuery1.Fields[j].FieldName='CYSJ' ) then
Repadoquery.fieldbyname('PICKDATE').Value:=ADOQuery1.fieldbyname('CYSJ').Value
else
Repadoquery.fieldbyname('ANADATE').Value:=ADOQuery1.fieldbyname('FXSJ').Value; end;
end;
Repadoquery.Post;
ADOQUERY1.Next;
end;
except
end; //try
end; i:=trunc((ZHJLfrReport.Pages[0].Prop['height']-
integer(ZHJLfrReport.Pages[0].Prop['topmargin'])-
integer(ZHJLfrReport.Pages[0].Prop['bottommargin'])-
integer(ZHJLfrReport.FindObject('页头1').Prop['height'])-
integer(ZHJLfrReport.FindObject('栏目脚1').Prop['height'])-
integer(ZHJLfrReport.FindObject('页脚1').Prop['height'])) /
integer(ZHJLfrReport.FindObject('主项数据1').Prop['height']));
if Repadoquery.RecordCount>0 then
if (RepADOQuery.RecordCount mod i)=0 then
i:=0
else
i:=i-Repadoquery.RecordCount mod i;
for j:=0 to i-1 do
begin
Repadoquery.Append;
Repadoquery.FieldByName('WID').AsString:='';
Repadoquery.Post;
end;
if ZHJLfrReport.PrepareReport then
ZHJLfrReport.ShowPreparedReport;
Repadoquery.CancelBatch(arall);
end;
这是代码 请大虾们帮我看看
这个问题的确很奇怪 在Delphi中编译后启动程序 就有这个问题 但是当我直接启动.exe文件 则没有这个问题了 真搞不懂事什么原因!!!