Delphi Operation Word Table

Source: Internet
Author: User
Tags rowcount

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.