Delphi Word Technology Fusion

xiaoxiao2021-04-09  439

procedure TExprmResultDlg.PreviewExprmReport; var Template, NewTemplate, DocumentType, OleVisible: oleVariant; strTitle_Prior, strText_Prior, strTitle_Last, strText_Last: String; begin Try Wordapplication1.Connect; Except Application.MessageBox ( 'you do not have Word installed applications, install Word2000, Then run this program! ',' System prompt ', MB_OK MB_ICONWARNING); ABORT; END;

Template: = EmptyParam; // Indicates that the template NEWTEMPLATE: = false; // indicates that the type of new new document is document

Doc.connectto (WordApplication1.Documents.add (Template, NewTemplate, DocumentType, Olevisible);

// Turn off the pinyin lookup and syntax looking to improve the efficiency of the program WordApplication1.Options.checkspellingsyOoutype: = false; WordApplication1.Options.checkgrammarasyoutype: = false;

// Add Header AddreppageHeader (18, Edit_Repheader.Text, AlCenter);

// Add Footer Page Code Set AddReppageFooder (1, AlCenter);

m_wordsesson: = WordApplication1.Selection; WordFont1.connectTo (M_WordSsson.font); WordFont1.name: = 'Song Body';

// Output report information addparagraphtitle ('module information'); // Add paragraph title

STRTITLE_PRIOR: = 'factory station name:'; strText_prior: = Edit_FactoryName.Text;

AddparaGraphContentsingle (start_prior, strtext_prior);

STRTITE_PRIOR: = 'Test:'; strText_Prior: = Edit_TestPEOSon.Text; start_last: = 'Test time:'; strText_last: = formatdatetime ('YYYY "Year" mm "month" DD "Day"', NOW);

AddparagraphContentDouble (start_prior, strtext_prior, strtitle_last, strtext_last);

// Output report content addparagraphtitle ('test result'); // Add paragraph title WritErEportInformation;

Addparagraphtitle ('Test Conclusion'); // Add paragraph title m_wordsesson.typeparagraph; m_wordsesson.typeparagraph; m_wordsesson.typeparagramr;

WordApplication1.disconnect;

END;

procedure TExprmResultDlg.AddRepPageHeader (const nFontSize: integer; const strText: String; Const PageFoodAlign: TPageFoodAlign); // add headers var alTextAlign: OleVariant; begin Case PageFoodAlign of alLeft: alTextAlign: = wdAlignParagraphLeft; alCenter: alTextAlign: = wdAlignParagraphCenter; alRight : alTextAlign: = wdAlignParagraphRight; alJustify: alTextAlign: = wdAlignParagraphJustify; end; WordApplication1.ActiveWindow.ActivePane.View.SeekView: = wdSeekCurrentPageHeader; WordApplication1.Selection.ParagraphFormat.Alignment: = alTextAlign;

WordApplication1.Selection.font.size: = 18; WordApplication1.Selection.Font.Color: = CLBLACK; WordApplication1.Selection.InsertAfter (strText); end;

procedure TExprmResultDlg.AddRepPageFooder (const nFistPageNum: integer; Const PageFoodAlign: TPageFoodAlign); // add a footer page set var mmm, nPageNum, aaa, alTextAlign: OleVariant; begin Case PageFoodAlign of alLeft: alTextAlign: = wdAlignParagraphLeft; alCenter: alTextAlign: = WDALIGNPARAGRAGRAGRIGN: = WDALIGNPARAGRAGRIGN: = WDALIGNPARAGRAGRAUSTINPARRAGRAUSTI

mmm: = wdLine; nPageNum: = nFistPageNum; aaa: = wdFieldPage; WordApplication1.ActiveWindow.ActivePane.View.SeekView: = wdSeekCurrentPageFooter; WordApplication1.Selection.Move (mmm, nPageNum); WordApplication1.Selection.ParagraphFormat.Alignment: = alTextAlign;

WordApplication1.Selection.InsertAfter ( 'on'); mmm: = wdCharacter; WordApplication1.Selection.Move (mmm, nPageNum); WordApplication1.Selection.Fields.Add (WordApplication1.Selection.Range, aaa, mmm, nPageNum);

aaa: = wdFieldNumPages; WordApplication1.Selection.InsertAfter ( '/ Total'); WordApplication1.Selection.Move (mmm, nPageNum); WordApplication1.Selection.Fields.Add (WordApplication1.Selection.Range, aaa, mmm, nPageNum); WordApplication1.Selection.Insertafter ('page'); WordApplication1.ActiveWindow.ActivePane.View.seekView: = WDSeekMainDocument; End;

procedure TExprmResultDlg.PastePicToWord (Const imageName: TImage); var AFormat: word; AData: cardinal; APalette: hpalette; begin imageName.Picture.SaveToClipboardFormat (AFormat, AData, APalette); Clipboard.SetAsHandle (AFormat, AData); doc.Sentences .Last.paste;

procedure TExprmResultDlg.AddParagraphTitle (const strTitle: String); // begin // add section header plus the Enter key, forming passages: ParaFmt.SpaceBefore: = 30; ParaFmt.SpaceAfter: = 30; //m_wordSesson.TypeParagraph; WordFont1.Size : = 14; WordFont1.bold: = 1; M_WordSsson.Typetext (Strtertle # 13);

M_TABLENUM: = M_TABLENUM 1;

END;

procedure TExprmResultDlg.AddParagraphContentSingle (Const strTitle, strText: String); var i: integer; TableBehavior, AutoFitbehavior: oleVariant; begin TableBehavior: = FALSE; AutoFitbehavior: = FALSE; Doc.Tables.Add (WordApplication1.Selection.Range, 1, 4 , Tablebehavior, Autofitbehavior; // Create a form

m_tablerow: = m_tableRow 1;

For i: = 1 to 4 do begin doc.tables.item (m_tablenum) .Cell (m_tablerow, i) .range.font.size: = 12; doc.tables.Item (m_tablenum) .Cell (m_tableRow, i). Range.font.bold: = 0;

// Remove the table border doc.tables.item (m_tablenum) .Cell (m_tablerow, i) .range.borders.Item (wdborderleft) .LINESTYLE: = WDLINESTYLENONED; DOC.TABLES.ITEM (M_TABLENUM) .Cell (m_tableRow, i) .Range.Borders.item (wdBorderRight) .LineStyle: = wdLineStyleNone; Doc.Tables.Item (m_tableNum) .Cell (m_tableRow, i) .Range.Borders.item (wdBorderTop) .LineStyle: = wdLineStyleNone; Doc.Tables.Item (m_tablenum) .cell (m_tablerow, i) .Range.Borders.Item (WDBORDERBOTTOM) .LINESTYLE: = WDLINESTYLENONEN; END; DOC.TABLES.ITEM (M_TABLENUM) .Cell (m_tableRow, 2) .mege (doc.tables.Item) (m_tablenum) .Cell (m_tablerow, 3)); doc.tables.Item (m_tablenum) .Cell (m_tablerow, 2) .merge (doc.tables.item (m_tablenum) .Cell (M_TableRow, 3));

Doc.Tables.Item (m_tableNum) .Cell (m_tableRow, 1) .Range.ParagraphFormat.Alignment: = wdAlignParagraphRight; Doc.Tables.Item (m_tableNum) .Cell (m_tableRow, 2) .Range.ParagraphFormat.Alignment: = wdAlignParagraphLeft;

Doc.tables.Item (m_tablenum) .Cell (m_tableRow, 1) .range.text: = start.Text: it (m_tablenum) .cell (m_tableron, 2) .range.text: = strText;

WordApplication1.Serection.seTRANGE (100 * m_tablerow, 100 * m_tablerow); // Set the paragraph range END;

procedure TExprmResultDlg.AddParagraphContentDouble (Const strTitle_Prior, strText_Prior, strTitle_Last, strText_Last: String); var i: integer; TableBehavior, AutoFitbehavior: oleVariant; begin TableBehavior: = FALSE; AutoFitbehavior: = FALSE; Doc.Tables.Add (WordApplication1.Selection.Range , 1, 4, Tablebehavior, Autofitbehavior; // Create Table M_TableRow: = M_TABLEROW 1;

For i: = 1 to 4 do begin doc.tables.item (m_tablenum) .Cell (m_tablerow, i) .range.font.size: = 12; doc.tables.Item (m_tablenum) .Cell (m_tableRow, i). Range.font.bold: = 0;

// Remove the table border doc.tables.item (m_tablenum) .Cell (m_tablerow, i) .range.borders.Item (wdborderleft) .LINESTYLE: = WDLINESTYLENONED; DOC.TABLES.ITEM (M_TABLENUM) .Cell (m_tableRow, i) .Range.Borders.item (wdBorderRight) .LineStyle: = wdLineStyleNone; Doc.Tables.Item (m_tableNum) .Cell (m_tableRow, i) .Range.Borders.item (wdBorderTop) .LineStyle: = wdLineStyleNone; Doc.Tables.Item (m_tableNum) .Cell (m_tableRow, i) .Range.Borders.item (wdBorderBottom) .LineStyle: = wdLineStyleNone; end; Doc.Tables.Item (m_tableNum) .Cell (m_tableRow, 1) .Range.ParagraphFormat.Alignment: = WDALIGNPARAGRAGRIGHT; doc.tables.item (m_tablenum) .Cell (m_tablerow, 2) .range.ParagraphFormat.Alignment: = WDALIGNPARAGRAGRAGRAGRAGRAGRAGRAGRAGRAGRAGRAGRAGRAGRAGRAGRAGRAGRAGRAGRATION

Doc.Tables.Item (m_tableNum) .Cell (m_tableRow, 3) .Range.ParagraphFormat.Alignment: = wdAlignParagraphRight; Doc.Tables.Item (m_tableNum) .Cell (m_tableRow, 4) .Range.ParagraphFormat.Alignment: = wdAlignParagraphLeft; Doc.tables.Item (m_tablenum) .Cell (m_tableRow, 1) .range.text: = start.Text: Doc.Tables.Item (m_tablenum) .Cell (M_TableRow, 2) .range.Text: = strText_Prior; Doc.Tables. Item (m_tablenum). Cell (M_TableRow, 3) .range.text: = start.Text; Doc.Tables.Item (m_tablenum) .Cell (m_tableRow, 4) .range.text: = strText_last;

WordApplication1.Serection.seTRANGE (100 * m_tablerow, 100 * m_tablerow); // Set the paragraph range END;

转载请注明原文地址:https://www.9cbs.com/read-133130.html

New Post(0)