L
lisawander
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm_gcjl1.Button1Click(Sender: TObject);
var
s:string;
mydoc,template,newtemplate,avar,vWhat,vWhich,vCount,vName,vUnit,vExtend,tablelevariant;
sheet:variant;
lj,lj1,jh:string;
cd,biaoz:integer;
i,page,i1,j1,i_nr,i_bl,page1:integer;
m,n,k:integer;
m1,m2,n1:string;
begin
jh:=DM.CurJingHao;
lj:=DM.MoBanPath+'gcjl.doc';
query1.close;
query1.SQL.clear;
query1.SQL.Add('select * from gcjl18 where id ='+id.text);
query1.prepared;
query1.open;
if query1.RecordCount <>0 then
begin
///////////////////打开模板/////////////////////////
mydoc:=lj;
template:=emptyparam;
newtemplate:=true;
try
wordapp1.Connect;
except
MessageDlg('请先打开Word', mtError, [mbOk], 0);
Abort;
end;
wordapp1.Visible:=true;
wordapp1.Caption:='观察记录报表';
wordapp1.Documents.OpenOld(mydoc,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam);
worddoc1.ConnectTo(wordapp1.ActiveDocument);
s:=query1.fieldbyname('jh').AsString;
mydoc:=s+'号井观察记录.doc';
worddoc1.SaveAs(mydoc);
////////////////定位到文档顶端/////////////////////
avar:=wdstory;
wordapp1.Selection.HomeKey(avar,emptyparam);
///////////////定位到下一个域/////////////////////
wordgotobookmark('jh');
WordApp1.Selection.TypeText(jh+'井');
Table:=WordDoc1.Tables.Item(1);
Table.Cell(1,2).Range.Text:=query1.FieldByName('rq').AsString;
Table.Cell(1,4).Range.Text:=query1.FieldByName('zbr').AsString;
Table.Cell(2,2).Range.Text:=query1.FieldByName('ztgf').AsString;
Table.Cell(2,4).Range.Text:=query1.FieldByName('yxtc').AsString+'m';
Table.Cell(2,6).Range.Text:=query1.FieldByName('shr').AsString;
Table.Cell(3,2).Range.Text:=query1.FieldByName('zt').AsString;
Table.Cell(3,4).Range.Text:=query1.FieldByName('zgc').AsString+'m';
Table.Cell(3,6).Range.Text:=query1.FieldByName('fr').AsString+'m';
Table.Cell(4,2).Range.Text:=query1.FieldByName('genru').AsString+'m';
Table.Cell(4,4).Range.Text:=query1.FieldByName('jbjs').AsString+'m';
Table.Cell(4,6).Range.Text:=query1.FieldByName('jjs').AsString+'m';
Table.Cell(4,8).Range.Text:=query1.FieldByName('jinc').AsString+'m';
//根据此记录内容的多少,分页???
table.cell(6,1).range.paste;
WordDoc1.Disconnect;
WordApp1.Disconnect;
end
else
begin
showmessage('对不起,现在数据库中还没有任何数据!');
biaoz:=2;
end;
if biaoz<>2 then showmessage('恭喜,报表已成功生成!');
close;
end;
var
s:string;
mydoc,template,newtemplate,avar,vWhat,vWhich,vCount,vName,vUnit,vExtend,tablelevariant;
sheet:variant;
lj,lj1,jh:string;
cd,biaoz:integer;
i,page,i1,j1,i_nr,i_bl,page1:integer;
m,n,k:integer;
m1,m2,n1:string;
begin
jh:=DM.CurJingHao;
lj:=DM.MoBanPath+'gcjl.doc';
query1.close;
query1.SQL.clear;
query1.SQL.Add('select * from gcjl18 where id ='+id.text);
query1.prepared;
query1.open;
if query1.RecordCount <>0 then
begin
///////////////////打开模板/////////////////////////
mydoc:=lj;
template:=emptyparam;
newtemplate:=true;
try
wordapp1.Connect;
except
MessageDlg('请先打开Word', mtError, [mbOk], 0);
Abort;
end;
wordapp1.Visible:=true;
wordapp1.Caption:='观察记录报表';
wordapp1.Documents.OpenOld(mydoc,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam);
worddoc1.ConnectTo(wordapp1.ActiveDocument);
s:=query1.fieldbyname('jh').AsString;
mydoc:=s+'号井观察记录.doc';
worddoc1.SaveAs(mydoc);
////////////////定位到文档顶端/////////////////////
avar:=wdstory;
wordapp1.Selection.HomeKey(avar,emptyparam);
///////////////定位到下一个域/////////////////////
wordgotobookmark('jh');
WordApp1.Selection.TypeText(jh+'井');
Table:=WordDoc1.Tables.Item(1);
Table.Cell(1,2).Range.Text:=query1.FieldByName('rq').AsString;
Table.Cell(1,4).Range.Text:=query1.FieldByName('zbr').AsString;
Table.Cell(2,2).Range.Text:=query1.FieldByName('ztgf').AsString;
Table.Cell(2,4).Range.Text:=query1.FieldByName('yxtc').AsString+'m';
Table.Cell(2,6).Range.Text:=query1.FieldByName('shr').AsString;
Table.Cell(3,2).Range.Text:=query1.FieldByName('zt').AsString;
Table.Cell(3,4).Range.Text:=query1.FieldByName('zgc').AsString+'m';
Table.Cell(3,6).Range.Text:=query1.FieldByName('fr').AsString+'m';
Table.Cell(4,2).Range.Text:=query1.FieldByName('genru').AsString+'m';
Table.Cell(4,4).Range.Text:=query1.FieldByName('jbjs').AsString+'m';
Table.Cell(4,6).Range.Text:=query1.FieldByName('jjs').AsString+'m';
Table.Cell(4,8).Range.Text:=query1.FieldByName('jinc').AsString+'m';
//根据此记录内容的多少,分页???
table.cell(6,1).range.paste;
WordDoc1.Disconnect;
WordApp1.Disconnect;
end
else
begin
showmessage('对不起,现在数据库中还没有任何数据!');
biaoz:=2;
end;
if biaoz<>2 then showmessage('恭喜,报表已成功生成!');
close;
end;