From:http://www.noobyard.com/article/p-hajevays-gs.html
。。。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
uses comobj, word2000 procedure TForm1.Button2Click(Sender: TObject); var WordApp, WordDoc,table: OleVariant; fileName : string; begin WordApp := CreateOleObject('Word.Application'); WordDoc := WordApp.Documents.Add;字体 try WordDoc.PageSetup.LeftMargin := 0.39*72; // 1 英寸 = 72 磅 WordDoc.PageSetup.RightMargin := 0.39*72; // 1 英寸 = 72 磅 WordDoc.PageSetup.TopMargin := 1*72; // 1 英寸 = 72 磅 WordDoc.PageSetup.BottomMargin := 1*72; // 1 英寸 = 72 磅 WordDoc.PageSetup.PaperSize := wdPaperA4; //A4纸ui WordApp.Selection.Font.Name := '黑体'; WordApp.Selection.Font.Size := 22;//二号字体 单位:磅 WordApp.Selection.Font.Bold := True;//字体加粗 WordApp.Selection.Font.Color := wdColorBlue;//字体颜色 WordApp.Selection.ParagraphFormat.Alignment := wdAlignParagraphCenter; //段落中文本居中 WordApp.Selection.ParagraphFormat.LineSpacingRule := wdLineSpaceSingle;//单倍行距 WordApp.Selection.TypeText('学生对教师教学工做整体评价'); WordApp.Selection.TypeParagraph;//回车 WordApp.Selection.TypeParagraph;//回车orm table := WordApp.ActiveDocument.Tables.Add(WordApp.ActiveDocument.Paragraphs.item(3).Range,2,5); //往第三段增长一表格(2行5列)blog WordApp.Selection.Font.Name := '宋体'; WordApp.Selection.Font.Size := 9; WordApp.Selection.Font.Bold := False; WordApp.Selection.Font.Color := wdColorBlack; table.cell(1,1).VerticalAlignment := wdCellAlignVerticalCenter; WordApp.Selection.TypeText('教师姓名');ci table.Cell(1, 1).Merge(table.Cell(2, 1));string table.Cell(1, 2).Merge(table.Cell(1, 5));it WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.Font.Name := '宋体'; WordApp.Selection.Font.Color := wdColorBlue; WordApp.Selection.Font.Bold := True; WordApp.Selection.Font.Size := 12; WordApp.Selection.TypeText('对 教 师 教 学 工 做 的 综 合 评 价'); WordApp.Selection.TypeParagraph; WordApp.Selection.MoveRight(wdCell,1);io WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.Font.Name := '宋体'; WordApp.Selection.Font.Color := wdColorBlack; WordApp.Selection.Font.Bold := True; WordApp.Selection.Font.Size := 12; WordApp.Selection.TypeText('A'); WordApp.Selection.TypeParagraph; WordApp.Selection.Font.Size := 9; WordApp.Selection.Font.Bold := False; WordApp.Selection.TypeText('很是满意');table WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.Font.Name := '宋体'; WordApp.Selection.Font.Color := wdColorBlack; WordApp.Selection.Font.Bold := True; WordApp.Selection.Font.Size := 12; WordApp.Selection.TypeText('B'); WordApp.Selection.TypeParagraph; WordApp.Selection.Font.Size := 9; WordApp.Selection.Font.Bold := False; WordApp.Selection.TypeText('满意');file WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.Font.Name := '宋体'; WordApp.Selection.Font.Color := wdColorBlack; WordApp.Selection.Font.Bold := True; WordApp.Selection.Font.Size := 12; WordApp.Selection.TypeText('C'); WordApp.Selection.TypeParagraph; WordApp.Selection.Font.Size := 9; WordApp.Selection.Font.Bold := False; WordApp.Selection.TypeText('基本满意'); WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.Font.Name := '宋体'; WordApp.Selection.Font.Color := wdColorBlack; WordApp.Selection.Font.Bold := True; WordApp.Selection.Font.Size := 12; WordApp.Selection.TypeText('D'); WordApp.Selection.TypeParagraph; WordApp.Selection.Font.Size := 9; WordApp.Selection.Font.Bold := False; WordApp.Selection.TypeText('不满意'); WordApp.Selection.MoveRight(wdCell,1);//新增一行 WordApp.Selection.Font.Name := '宋体'; WordApp.Selection.Font.Color := wdColorBlack; WordApp.Selection.Font.Bold := false; WordApp.Selection.Font.Size := 10.5; WordApp.Selection.TypeText('教师A'); WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.Font.Name := '宋体'; WordApp.Selection.Font.Color := wdColorBlack; WordApp.Selection.Font.Bold := true; WordApp.Selection.Font.Size := 12; WordApp.Selection.TypeText('94'); WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.TypeText('6'); WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.TypeText('0'); WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.TypeText('0'); WordApp.Selection.MoveRight(wdCell,1);//新增一行 WordApp.Selection.Font.Name := '宋体'; WordApp.Selection.Font.Color := wdColorBlack; WordApp.Selection.Font.Bold := false; WordApp.Selection.Font.Size := 10.5; WordApp.Selection.TypeText('教师B'); WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.Font.Name := '宋体'; WordApp.Selection.Font.Color := wdColorBlack; WordApp.Selection.Font.Bold := true; WordApp.Selection.Font.Size := 12; WordApp.Selection.TypeText('92'); WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.TypeText('8'); WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.TypeText('0'); WordApp.Selection.MoveRight(wdCell,1); WordApp.Selection.TypeText('0'); table.Rows.Alignment := wdAlignRowCenter;//表格居中 table.Borders.Item(wdBorderLeft).LineStyle:=wdLineStyleSingle; table.Borders.Item(wdBorderRight).LineStyle:=wdLineStyleSingle; table.Borders.Item(wdBorderTop).LineStyle:=wdLineStyleSingle; table.Borders.Item(wdBorderBottom).LineStyle:=wdLineStyleSingle; table.Borders.Item(wdBorderHorizontal).LineStyle:=wdLineStyleSingle; table.Borders.Item(wdBorderVertical).LineStyle:=wdLineStyleSingle; fileName := ExtractFilePath(ParamStr(0)) + '整体总评.doc'; WordDoc.saveas(fileName); finally WordDoc.Saved := True; WordDoc.Close; WordApp.Quit; end; ShowMessage('ok'); end; |
