WordDocument1: TWordDocument;
WordApplication1: TWordApplication;
Table1:TTable;
procedure TForm1.Button1Click(Sender: TObject);
var
I,j,k,RowCount,ColCount:integer;
begin
WordDocument1.ConnectTo(WordApplication1.ActiveDocument);
ColCount:=Table1.FieldCount;
RowCount:=Table1.RecordCount+1;
WordDocument1.Paragraphs.Last.Range.InsertAfter(#13#10);
WordDocuMent1.Tables.Add(WordDocument1.Paragraphs.Last.Range,RowCount,ColCount,EmptyParam,EmptyParam);
with wordDocument1.Tables.Item(WordDocument1.Tables.Count).Rows do
begin
for i:=0 to ColCount-1 do
Item(1).Cells.Item(i+1).Range.Text:=Table1.Fields.Fields.DisplayLabel;//±íÍ·
for i:=2to RowCountdo //ÄÚÈÝ
for j:=0 to ColCount-1 do
Item(i).Cells.Item(j+1).Range.Text:=Table1.Fields.Fields[j].DisplayLabel;
end;
end;
end.