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没有安装', '提示信息', 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;
// wrdSelection.TypeText('打印时间:' + FormatDateTime('yyyy年hh月dd日 hh时MM分ss秒', Now));
// strAdd := '进样时间:' + FormatDateTime('yyyy年hh月dd日 hh时MM分ss秒', Now) + ' , 操作人:unknown';
// wrdSelection.TypeText(stradd);
// wordApp.selection.TypeParagraph;//换行
// strAdd := '质检(E)字第()号';
// wrdSelection.TypeText(stradd);
// wordApp.selection.TypeParagraph;//换行
// strAdd := '进样单位: ' + ' 仪器型号:SC-1001-09A';
// wrdSelection.TypeText(stradd);
// wordApp.selection.TypeParagraph;//换行
// strAdd := '取样日期:' + FormatDateTime('yyyy年hh月dd日 ', Now) + ' 取样日期:' + FormatDateTime('yyyy年hh月dd日 ', Now);
// wrdSelection.TypeText(stradd);
// wordApp.selection.TypeParagraph;//换行
// strAdd := '样品批号: ' + ' 样品名称:固液' ;
// wrdSelection.TypeText(stradd);
// wordApp.selection.TypeParagraph;//换行
// strAdd := '样品罐号: ' ;
// wrdSelection.TypeText(stradd);
wordApp.selection.TypeParagraph;//换行
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;
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 操作word 表格的更多相关文章

  1. 黄聪:C#操作Word表格的常见操作(转)

    几种常见C#操作Word表格操作有哪些呢?让我们来看看具体的实例演示: bool saveChange = false; //C#操作Word表格操作 object missing = System. ...

  2. 转发:VB程序操作word表格(文字、图片)

    很多人都知道,用vb操作excel的表格非常简单,但是偏偏项目中碰到了VB操作word表格的部分,google.baidu搜爆了,都没有找到我需要的东西.到是搜索到了很多问这个问题的记录.没办法,索性 ...

  3. Java 操作Word表格——创建嵌套表格、添加/复制表格行或列、设置表格是否禁止跨页断行

    本文将对如何在Java程序中操作Word表格作进一步介绍.操作要点包括 如何在Word中创建嵌套表格. 对已有表格添加行或者列 复制已有表格中的指定行或者列 对跨页的表格可设置是否禁止跨页断行 创建表 ...

  4. Java 操作Word表格

    本文将对如何在Java程序中操作Word表格作进一步介绍.操作要点包括 如何在Word中创建嵌套表格. 对已有表格添加行或者列 复制已有表格中的指定行或者列 对跨页的表格可设置是否禁止跨页断行 创建表 ...

  5. c#操作word表格

    http://www.webshu.net/jiaocheng/programme/ASPNET/200804/6499.html <% if request("infoid" ...

  6. delphi 操作 word

        uses  ComObj,word2000   procedure TForm1.ExportWord(); var FWord :Variant; FDoc :Variant; i,Row: ...

  7. Aspose.Word 操作word表格的行 插入行 添加行

    rows.insert或rows.add前row必须有单元格cell private void button3_Click(object sender, EventArgs e) {         ...

  8. Aspose.Words.Tables.Row类操作word表格行

    http://www.aspose.com/docs/display/wordsnet/Aspose.Words.Tables.Row+Class Retrieves the index of a r ...

  9. Delphi 操作Word怎么控制光标的位置

    unit ControlWordS; interface uses Classes, Sysutils, Word97; type  TControlWord = class(TComponent)  ...

随机推荐

  1. DB2 中将date类型的转换成timestamp

    方法1: TIMESTAMP(Char(date)||'00.00.00') SELECT T2.RECORDNO,T2.DANGERTIME,T2.BIZORIGIN,T3.COMMONNAME A ...

  2. ASP .net(照片列表详细功能演示)

    大家好,今天我们需要讲解的内容就是把上篇文章当中提到的照片列表的很多功能细化去做. 那么之间我们两篇文章的目的就是要让大家深刻体会get,post的使用场景极其作用.像一般处理程序的使用,隐藏域的使用 ...

  3. DML、DDL、DCL区别

    1.DML:数据操纵语言.执行完需要提交,有回滚. select.insert.update.delete.call explain plan :Oracle RDBMS执行每一条SQL语句,都必须经 ...

  4. MQTT之 Mosquitto hello world的使用

    服务端发布消息模式,客户端订阅: 终端一中启动 moquitto 服务器 shallbeThatIshallbe:mosquitto iamthat$ 1427293344: Opening ipv4 ...

  5. PKUSC 模拟赛 day1 上午总结

    思考了一下第二题,觉得有无数种乱搞做法 类似什么bitset压位,MCS染色之类奇怪的做法 然而都是玄学正确性或者玄学复杂度 先放题解把 第一题显然具有单调性,二分就可以啦 O(nlogn),貌似输出 ...

  6. Xamarin.Android 入门之:Bind java的jar文件+Android显示gif图片

    一.引言 在xamarin开发的时候,有时我们想要做一个功能,但是这个功能已经有人用java写好了,并且打包成了jar文件.那么我们可以直接把对方的jar文件拿过来用而不是重新用c#写代码. 关于bi ...

  7. Winsock完成端口模型-Delphi代码

    原文出处 <Windows网络编程技术>第8章 完成端口模型 由于原书附的是C代码,我把其翻译成Delphi代码. 其中winsock2.pas在delphi中不带,要另外下载http:/ ...

  8. Android:控件的隐藏显示

    布局中的:android:visibility 程序中可用setVisibility(); 对应的三个常量值:0.4.8 VISIBLE:0 意思是可见的INVISIBILITY:4 意思是不可见的, ...

  9. tomcat作为windows服务启动失败解决方法

    再使用如下方法注册windows服务时,出现问题: set CATALINA_BASE=E:\tomcat\tomcat-web-server set CATALINA_HOME=E:\tomcat\ ...

  10. Could not write to output file 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\xx'

    1.清了C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files 2.给上述文件夹EveryOne和IIS_Use ...