Delphi 712操作word
//导出Word
procedure TFrm_Computing.ExportWord;
var
wordApp, WordDoc, WrdSelection, wrdtable, wrdtable1, cell: variant;
strAdd: string;
wdPar,wdRange:OleVariant;
iCol, iRow, I, J: Integer;
begin
try
wordApp := CreateOleObject('Word.Application');
except
Application.MessageBox('Word没有安装', '提示信息', 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分析报告';
//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;//换行
wrdSelection.Font.bold := false;
wrdSelection.Font.Size := 10;
wrdSelection.Font.bold := false;
wrdSelection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;
wdPar:=WordApp.ActiveDocument.Paragraphs.Add;
wdRange:=wdPar.Range;
wdRange := wordApp.ActiveDocument.Content;
wdRange.Collapse(wdCollapseEnd);
iRow := 12;
iCol := 2;
wrdtable := wordDoc.Tables.Add(wdRange,iRow, iCol);
wrdtable.Cell(1, 1).Merge(wrdtable.Cell(1, 2));
wrdtable.Cell(2, 1).Merge(wrdtable.Cell(2, 2));
wrdtable.Cell(1,1).Range.Text:= '打印时间:' + FormatDateTime('yyyy年hh月dd日 hh时MM分ss秒', Now);
wrdtable.Cell(2,1).Range.Text:= '进样时间:' + FormatDateTime('yyyy年hh月dd日 hh时MM分ss秒', Now);
wrdtable.Cell(3,1).Range.Text:= '质检(E)字第()号';
wrdtable.Cell(4,1).Range.Text:= '送样单位:' + 'XXX公司';
wrdtable.Cell(4,2).Range.Text:= '仪器型号:' + 'SC-1001-09A';
wrdtable.Cell(5,1).Range.Text:= '取样日期:' + FormatDateTime('yyyy年hh月dd日 ', Now);
wrdtable.Cell(5,2).Range.Text:= '收样日期:' + FormatDateTime('yyyy年hh月dd日 ', Now);
wrdtable.Cell(6,1).Range.Text:= '样品批号:' + '';
wrdtable.Cell(6,2).Range.Text:= '样品名称:' + '固液';
wrdtable.Cell(7,1).Range.Text:= '样品罐号:' + 'A-1-2';
wrdtable.Cell(8,1).Range.Text:= '仪器文件控制参数:' + '#1111';
wrdtable.Cell(9,1).Range.Text:= '';
wrdtable.Cell(10,1).Range.Text:= 'C:\AAAAAAA\111.bmp';
wrdtable.Cell(11,1).Range.Text:= '';
wrdtable.Cell(12,1).Range.Text:= '';
wordApp.selection.TypeParagraph;//换行
wordApp.selection.TypeParagraph;//换行
wordApp.selection.movedown(wdLine, 17);
wordApp.selection.paste;
wordApp.selection.TypeParagraph;//换行
wordApp.selection.TypeParagraph;//换行
wordApp.selection.TypeParagraph;//换行
wdPar:=WordApp.ActiveDocument.Paragraphs.Add;
wdRange:=wdPar.Range;
wdRange := wordApp.ActiveDocument.Content;
wdRange.Collapse(wdCollapseEnd);
iRow := SGrid_PeakResult.RowCount;
iCol := SGrid_PeakResult.ColCount;
wrdtable1 := 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
//ShowMessage(SGrid_PeakResult.Cells[J, I]);
wrdtable1.Cell(I +1,J + 1).Range.Text:= SGrid_PeakResult.Cells[J, I];
end;
end;
wrdtable1.columns.item(2).width := 80;
wrdtable1.rows.item(2).Borders.Item(wdBorderTop).LineStyle:=wdLineStyleSingle; //控制单行是否有线
wrdtable1.rows.item(2).Borders.Item(wdBorderTop).LineWidth:= wdLineWidth150pt; //控制单行的样式的线宽
wrdtable1.Rows.Item(1).Cells.VerticalAlignment:=wdCellAlignVerticalCenter;
wrdtable1.Borders.Item(wdBorderTop).LineStyle:=wdLineStyleSingle;
wrdtable1.Borders.Item(wdBorderBottom).LineStyle:=wdLineStyleSingle;
// wrdtable1.Borders.Item(wdBorderLeft).LineStyle:=wdLineStyleSingle;
// wrdtable1.Borders.Item(wdBorderRight).LineStyle:=wdLineStyleSingle;
// wrdtable1.Borders.Item(wdBorderHorizontal).LineStyle:=wdLineStyleSingle;
wrdtable1.Borders.Item(wdBorderTop).LineWidth:= wdLineWidth150pt; //
wrdtable1.Borders.Item(wdBorderBottom).LineWidth:= wdLineWidth150pt; //
wrdtable1.Borders.Item(wdBorderBottom).LineStyle:= wdLineStyleSingle; //
// wrdtable1.Borders.Item(wdBorderLeft).LineStyle:=wdLineStyleSingle;
// wrdtable1.Borders.Item(wdBorderRight).LineStyle:=wdLineStyleSingle;
// wrdtable1.Borders.Item(wdBorderTop).LineStyle:=wdLineStyleSingle;
// wrdtable1.Borders.Item(wdBorderBottom).LineStyle:=wdLineStyleSingle;
// wrdtable1.Borders.Item(wdBorderHorizontal).LineStyle:=wdLineStyleSingle;
// wrdtable1.Borders.Item(wdBorderVertical).LineStyle:=wdLineStyleSingle;
// wrdtable1.Borders.Item(wdBorderVertical).LineWidth:= wdLineWidth150pt; //
//选择左边的表格
//Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
//Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
//选择右边的表格
////Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone
end;
Delphi 712操作word的更多相关文章
- delphi 换行操作 Word
delphi 换行操作 我将我的商用<旅行社管理系统>的 发团通知 部分奉献给您,望对您有所帮助. procedure TFrmMain.N327Click(Sender: TObject ...
- Delphi中编辑word
其他(28) //启动Word try wordapplication1.connect; except messagedlg('word may not be ins ...
- python操作word入门
1.安装pywin32 http://sourceforge.net/projects/pywin32 在files里去找适合你的python版本.截止此文,最新版本是pywin32-219快捷路径: ...
- C#中操作Word(1)—— word对象模型介绍
一.开发环境布置 C#中添加对Word的支持,只需添加对Microsoft.Office.Interop.Word的命名空间,如下图所示,右键点击“引用”,在弹出的“添加引用”对话框中选中COM标签页 ...
- C#操作Word的超详细总结
本文中用C#来操作Word,包括: 创建Word: 插入文字,选择文字,编辑文字的字号.粗细.颜色.下划线等: 设置段落的首行缩进.行距: 设置页面页边距和纸张大小: 设置页眉.页码: 插入图片,设置 ...
- C#操作word模板插入文字、图片及表格详细步骤
c#操作word模板插入文字.图片及表格 1.建立word模板文件 person.dot用书签 标示相关字段的填充位置 2.建立web应用程序 加入Microsoft.Office.Interop.W ...
- Delphi Excel 操作大全
Delphi Excel 操作大全 (一) 使用动态创建的方法首先创建 Excel 对象,使用ComObj:var ExcelApp: Variant;ExcelApp := CreateOleObj ...
- C#操作Word的辅助类(word2003) 修改完善版
转自:http://blog.csdn.net/jiutao_tang/article/details/6567608 该类在他人编写的几个类基础上扩展完善而来,主要功能有: (1)插入文本 (2)插 ...
- 黄聪:C#操作Word表格的常见操作(转)
几种常见C#操作Word表格操作有哪些呢?让我们来看看具体的实例演示: bool saveChange = false; //C#操作Word表格操作 object missing = System. ...
随机推荐
- Java Socket文件上传
客户端: import java.io.FileInputStream; import java.net.Socket; /** * Created by 290248126 on 14-5-11. ...
- leetcode 5 :Longest Palindromic Substring 找出最长回文子串
题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum l ...
- MSSQLServer基础06(变量,case,选择语句)
变量 声明:declare @UserName nvarchar(50) 赋值1:set @UserName=N'杨':修改 赋值2:select @UserName=N'牛':修改 输出:print ...
- Android Handler值传递(文)
发送消息: public static class TimeReceiver extends BroadcastReceiver { @Override public void onReceive(C ...
- Android Include标签
编程的世界有的时候很微妙,有的时候就好像是在解决一个哲学问题,Android开发的时候,所有的布局,颜色,等(其实这些都可以称之为资源,Android中的资源是指非代码部分,如图片.音频.视频.字符等 ...
- JDBC学习总结(一)
1.JDBC概述 JDBC是一种可以执行SQL语句并可返回结果的Java API,其全称是Java DataBase Connectivity,也是一套面向对象的应用程序接口API,它由一组用 ...
- windows和linux共享文件
一篇文章: 环境:主机操作系统 是Windows XP ,虚拟机 是Ubuntu 9.10,虚拟机是VirtualBox 3.08. 1. 安装增强功能包(Guest Additions) 安装好Ub ...
- 方法Equals和操作符==的区别
http://www.codeproject.com/Articles/584128/What-is-the-difference-between-equalsequals-and-Eq When w ...
- 迷宫问题(bfs的应用)
问题描述: 定义一个二维数组N*M(其中2<=N<=10;2<=M<=10),如5 × 5数组下所示: int maze[5][5] = { 0, 1, 0, 0, 0, 0, ...
- HDU 1677
Nested Dolls Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...