delphi通过OLE对word进行单元格合并操作
来源:互联网 发布:java获取session对象 编辑:程序博客网 时间:2024/05/07 13:23
上图为最终结果,
直接上代码:
uses comobj, word2000procedure 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纸 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;//回车 table := WordApp.ActiveDocument.Tables.Add(WordApp.ActiveDocument.Paragraphs.item(3).Range,2,5); //往第三段增加一表格(2行5列) 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('教师姓名'); table.Cell(1, 1).Merge(table.Cell(2, 1)); table.Cell(1, 2).Merge(table.Cell(1, 5)); 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); 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('非常满意'); 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('满意'); 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;
- delphi通过OLE对word进行单元格合并操作
- POI操作word合并单元格
- poi操作Word合并单元格
- 用Delphi合并Word表格中单元格
- Delphi中通过OLE来操作Excel
- Delphi与Word(一)合并Word 表格中单元格
- Delphi与Word(一) 合并Word 表格中单元格
- 如何对合并单元格进行筛选
- BCB中通过OLE对Word中的XML节点设置
- target操作,对当前单元格进行操作
- 【一步一步学习VBA】WORD 中创建表格进行单元格合并
- delphi excel 单元格合并
- PowerPoint, Word, Ole操作
- 通过XML对Word操作
- 对Word进行各种操作
- Delphi对并口进行操作!
- vc操作excel,包括合并单元格,新增,删除sheet,设置字体,底色(OLE/COM)
- 在Delphi中使用CreateOleObject方法对WORD文件进行操作
- 关于文件系统
- 在MAC OS X中默认的Web共享目录
- PHP设计模式系列 - 中介者模式
- 一、重构,第一案例
- js做的一个钟表,带指针的
- delphi通过OLE对word进行单元格合并操作
- uboot简要分析
- 游戏中的状态机
- lr_eval_string;sprintf;lr_save_string;用法
- 字符串指针 与 字符数组
- j2ee异常处理机制
- day16综合练习
- 整理的一些关于apache traffic server的FAQ条目
- [搬家]BMP与DPI