1: Make the data in the table into the form of Word
The Delphi code is as follows:
procedure TForm1.bbtn1Click (Sender: TObject); var WordApp, WordDoc, WordTable: OleVariant; i, j: integer; begin ADOQuery1.Open; WordApp: = CreateOleObject ( 'Word.Application'); WordApp.Visible: = True; WordDoc : = WordApp.documents.add; WordTable: = WordDoc.tables.add (Wordapp.Serection.Range, AdoQuery1.Recordcount 1, AdoQuery1.fieldcount);
For i: = 1 to adoquery1.fieldcount do begin wordtable.cell (1, i) .Range.insertAfter (adoQuery1.fields [i-1] .fieldname); end; i: = 2; with adoQuery1 do while not Eof do Begin for j: = 1 to adoquery1.fields.count do begin wordtable.cell (i, j) .Range.insertafter (adoQuery1.fields [j-1] .sstring); end; next; inc (i); END;
Among them, adoquery1.open; get SQL statement is 'SELECT * from 1_WZ'
Run as shown below:
--- to be continued by Littleroy