创建表格} WordRange:=WordDocument1.Range(aTemp,Position_b); vNumRows:=ADOQuery1.RecordCount; vNumColumns:=ADOQuery1.FieldCount; WordDocument1.Tables.AddOld(WordRange,vNumRows,vNumColumns); WordTable:=WordDocument1.Tables.Item(item); T:=WordTable; WordTable:=nil; WordRange:=nil; vNumRows:=NULL(); { NULL() is in unit Variant } vNumColumns:=NULL(); ADOQuery1.First; {向表格插入数据库记录} i:=1; while not ADOQuery1.Eof do begin j:=0; while j<ADOQuery1.FieldCount do begin T.cell(i,j+1).range.text:=ADOQuery1.Fields[j].AsString; inc(j); end; inc(i); ADOQuery1.Next; end;
WordRange:=WordDocument1.Range(aTemp,Position_b);
vNumRows:=ADOQuery1.RecordCount;
vNumColumns:=ADOQuery1.FieldCount;
WordDocument1.Tables.AddOld(WordRange,vNumRows,vNumColumns);
WordTable:=WordDocument1.Tables.Item(item); T:=WordTable;
WordTable:=nil;
WordRange:=nil;
vNumRows:=NULL(); { NULL() is in unit Variant }
vNumColumns:=NULL();
ADOQuery1.First; {向表格插入数据库记录}
i:=1;
while not ADOQuery1.Eof do
begin
j:=0;
while j<ADOQuery1.FieldCount do
begin
T.cell(i,j+1).range.text:=ADOQuery1.Fields[j].AsString;
inc(j);
end;
inc(i);
ADOQuery1.Next;
end;
在Delphi的OLE中调用就可以了!
在Word中用宏来画表格 我还没用过,
你可不可以介绍一下?谢谢