Var
WordApp, WordDoc, wrdselection, wrdtable:variant;
stradd:string;
Wdpar,wdrange:olevariant;
Icol, IRow, I, J:integer;
Begin
Try
WordApp: = Createoleobject (' Word.Application ');
Except
Application.messagebox (' Word not installed ', ' hint info ', mb_ok+mb_iconasterisk+mb_defbutton1+mb_applmodal);
Exit;
End
Self.Chart_Edit.CopyToClipboardBitmap;
Wordapp.visible: = true;
Worddoc:=wordapp.documents.add ();
Worddoc.select;
wrdselection: = wordapp.selection;
stradd:= ' xxx analysis report ';
stradd:= Format (Stradd, [FormatDateTime (' YYYY ', date), WeekOfYear (date)]);
Wrdselection.paragraphformat.alignment:=wdalignparagraphcenter;
WrdSelection.Font.bold: = true;
WrdSelection.Font.Size: = 15;
Wrdselection.typetext (Stradd);
wordapp.selection.typeparagraph;//line break
WrdSelection.Font.bold: = false;
WrdSelection.Font.Size: = 10;
WrdSelection.Font.bold: = false;
Wrdselection.paragraphformat.alignment:=wdalignparagraphleft;
Wrdselection.typetext (' Print time: ' + formatdatetime (' yyyy year HH month DD Day hh ' mm min ss sec ', now));
Stradd: = ' injection time: ' + formatdatetime (' yyyy year HH month DD Day hh mm ss seconds ', now) + ', Operator: unknown ';
Wrdselection.typetext (Stradd);
wordapp.selection.typeparagraph;//line break
Stradd: = ' quality inspection (E) Word No. ';
Wrdselection.typetext (Stradd);
wordapp.selection.typeparagraph;//line break
Stradd: = ' injection unit: ' + ' instrument model: sc-1001-09a ';
Wrdselection.typetext (Stradd);
wordapp.selection.typeparagraph;//line break
Stradd: = ' Sampling date: ' + formatdatetime (' yyyy ' HH month DD Day ', now) + ' sampling Date: ' + formatdatetime (' yyyy year HH month DD ', now);
Wrdselection.typetext (Stradd);
wordapp.selection.typeparagraph;//line break
Stradd: = ' sample lot: ' + ' sample name: solid Liquid ';
Wrdselection.typetext (Stradd);
wordapp.selection.typeparagraph;//line break
Stradd: = ' Sample tank number: ';
Wrdselection.typetext (Stradd);
wordapp.selection.typeparagraph;//line break
WordApp.selection.paste;
wordapp.selection.typeparagraph;//line break
wordapp.selection.typeparagraph;//line break
wordapp.selection.typeparagraph;//line break
Wdpar:=wordapp.activedocument.paragraphs.add;
Wdrange:=wdpar.range;
Wdrange: = wordApp.ActiveDocument.Content;
Wdrange.collapse (wdCollapseEnd);
IRow: = Sgrid_peakresult.rowcount;
Icol: = Sgrid_peakresult.colcount;
Wrdtable: = WordDoc.Tables.Add (Wdrange,irow, icol);
For I: = 0 to Sgrid_peakresult.rowcount-1 do
Begin
For J: = 0 to Sgrid_peakresult.colcount-1 do
Begin
Wrdtable. Cell (I,J). Range.text:= sgrid_peakresult.cells[j, I];
End
End
Wrdtable. Borders.item (Wdborderleft). Linestyle:=wdlinestylesingle;
Wrdtable. Borders.item (wdborderright). Linestyle:=wdlinestylesingle;
Wrdtable. Borders.item (Wdbordertop). Linestyle:=wdlinestylesingle;
Wrdtable. Borders.item (Wdborderbottom). Linestyle:=wdlinestylesingle;
Wrdtable. Borders.item (wdborderhorizontal). Linestyle:=wdlinestylesingle;
Wrdtable. Borders.item (wdbordervertical). Linestyle:=wdlinestylesingle;
Wrdtable. Borders.item (wdbordervertical). Linewidth:= wdlinewidth150pt; //
End
Delphi Operation Word Table