delphi 712 Word 2
//导出Word
procedure TFrm_Computing.ExportWord(aFileName: string; aFileType: string);
var
wordApp, WordDoc, WrdSelection, wrdtable, wrdtable1, cell: variant;
strAdd: string;
wdPar,wdRange:OleVariant;
iCol, iRow, I, J: Integer;
vNode: TcxTreeListNode;
vcolumn: TcxTreeListColumn;
str: string;
begin
try
wordApp := CreateOleObject('Word.Application');
except
Application.MessageBox('Word没有安装', '提示信息', MB_OK+MB_ICONASTERISK+MB_DEFBUTTON1+MB_APPLMODAL);
Exit;
end;
Self.cht_Edit.CopyToClipboardBitmap;
wordApp.Visible := false;
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 := RzRichEdit_ReportTop.Lines.Count;
iCol := 1;
wrdtable := wordDoc.Tables.Add(wdRange,iRow, iCol);
for I := 0 to RzRichEdit_ReportTop.Lines.Count -1 do
begin
wrdtable.Cell(I, 1).Range.Text := RzRichEdit_ReportTop.Lines.Strings[I];
end;
wordApp.selection.TypeParagraph;//换行
wordApp.selection.movedown(wdLine, 17);
wordApp.selection.paste;
wordApp.selection.TypeParagraph;//换行
wordApp.selection.TypeParagraph;//换行
wdPar:=WordApp.ActiveDocument.Paragraphs.Add;
wdRange:=wdPar.Range;
wdRange := wordApp.ActiveDocument.Content;
wdRange.Collapse(wdCollapseEnd);
iRow := SGrid_PeakResult.Count;
iCol := SGrid_PeakResult.ColumnCount;
wrdtable1 := wordDoc.Tables.Add(wdRange,iRow, iCol);
for I := 0 to SGrid_PeakResult.Count -1 do
begin
vNode := SGrid_PeakResult.Items[I];
for J := 0 to SGrid_PeakResult.ColumnCount -1 do
begin
vcolumn := SGrid_PeakResult.Columns[J];
wrdtable1.Cell(I +1,J + 1).Range.Text:= vNode.Texts[vcolumn.ItemIndex];
end;
end;
wrdtable1.columns.item(2).width := 60;
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.columns.item(3).width := 60;
wrdtable1.columns.item(4).width := 60;
wrdtable1.columns.item(8).width := 60;
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; //
wdPar:=WordApp.ActiveDocument.Paragraphs.Add;
wdRange:=wdPar.Range;
wdRange := wordApp.ActiveDocument.Content;
//该方法用于将指定区域折叠到起始位置或结束位置。
wdRange.Collapse(wdCollapseEnd);
iRow := RzRichEdit_ReportBottom.Lines.Count;
iCol := 1;
wrdtable := wordDoc.Tables.Add(wdRange,iRow, iCol);
for I := 0 to RzRichEdit_ReportBottom.Lines.Count -1 do
begin
wrdtable.Cell(I, 1).Range.Text := RzRichEdit_ReportBottom.Lines.Strings[I];
end;
wordApp.Visible := True;
if AnsiSameText(aFileType, 'doc') then
begin
wordDoc.saveas(aFileName, wdFormatDocument);
end
else if AnsiSameText(aFileType, 'rtf') then
begin
str := aFileName;
str := ChangeFileExt(str , '.rtf');
wordDoc.saveas(str, wdFormatRTF);
end;
end;
delphi 712 Word 2的更多相关文章
- Delphi读取Word
Delphi读取Word现在关于往Word中写入数据的方法比较多,现在专门开个贴子,希望大家把自己读取Word内容的心得体会说一下,包括读取word文档中,有几个段落,如何读取第几个段落,读取有拼音的 ...
- delphi控制 word的几种方法--转
对几种方法的难易程度的判别 a.通过Delphi的控件TOleContainer 将Word嵌入 这是最简单的Ole嵌入,能够直接将Word文档调用,只需要使用ToleContainer.Run就可以 ...
- Delphi 统计Word文档中的字数
急待解决的问题就是如何用delphi实现word中的统计字数 另外想多了解一些关于操作word的相关内容 比如用ole动态创建的和TWordApplication的偏重点在哪里,有什么不同等等…… 用 ...
- delphi控制word 标题 字符和位置
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...
- Delphi 712操作word
//导出Wordprocedure TFrm_Computing.ExportWord;var wordApp, WordDoc, WrdSelection, wrdtable, wrdtable1, ...
- 用Delphi进行word开发
使用以CreateOleObjects方式调用Word 实际上还是Ole,但是这种方式能够真正做到完全控制Word文件,能够使用Word的所有属性,包括自己编写的VBA宏代码.------------ ...
- Delphi对Word的基本操作
一.Delphi程序启动Word 采用CreateOleObjects的方法来启动Word,调用VBA代码,具体实现过程为: 首先使用GetActiveOleObject('Word.Applicat ...
- Delphi 运行Word VBA 宏 删除软回车
Sub 整理网页()'整理网页:删除软回车.删除空白段.使段落文字两端对齐Selection.WholeStory Selection.Find.ClearFormatting S ...
- delphi 操作 word
uses ComObj,word2000 procedure TForm1.ExportWord(); var FWord :Variant; FDoc :Variant; i,Row: ...
随机推荐
- Java笔记——equals和==的区别
摔在这里几次,还是记下来吧. 原文:http://www.cnblogs.com/shenliang123/archive/2012/04/16/2452156.html -------------- ...
- HTML5文档结构语义:页眉的header和hgroup标签使用
HTML5提供了新的结构元素——例如header.hgroup.article.section.footer.nav等来定义网页,将使网页结构更加简洁严谨,语义更加结构化,而不用迂回通过class或i ...
- Tomcat常见内存溢出的解决办法
PermGen space错误解决方法 在看下文之前,首先要确认意见事情,就是你是如何启动tomcat的,我们在平时的开发环境当中,都是通过startup.bat方式启动tomcat的,那么你按照下面 ...
- MyBatis学习总结_04_解决字段名与实体类属性名不相同的冲突
一.准备演示需要使用的表和数据 CREATE TABLE orders( order_id INT PRIMARY KEY AUTO_INCREMENT, order_no VARCHAR(20), ...
- 怎样做出优秀的扁平化设计风格 PPT 或 Keynote 幻灯片演示文稿?(装)
不知道你有没有想过,为什么很人多的扁平化 PPT 是这个样子: 或者是这样: 然而,还有一小撮人的扁平化 PPT 却拥有那么高颜值: 为什么会产生这么大的差距呢?丑逼 PPT 应该如何逆袭成为帅逼呢? ...
- Data Base MongoVue 破解治标不治本
MongoVue 破解治标不治本 ---------解决燃眉之急 注册表中查找B1159E65-821C3-21C5-CE21-34A484D54444中的子项4FF78130 ,删除其下的三个子项 ...
- 《Linux内核设计与实现》读书笔记 - 目录 (完结)【转】
转自:http://www.cnblogs.com/wang_yb/p/3514730.html 读完这本书回过头才发现, 第一篇笔记居然是 2012年8月发的, 将近一年半的时间才看完这本书(汗!! ...
- eclipse中启动tomcat报错 java.lang.ClassNotFoundException
之前启动还好好的,某次启动tomcat就莫名其妙的报了这个java.lang.ClassNotFoundException的错. 检查maven依赖包,发现这个类是存在的. 然后一通clean操作 ...
- C# 时间戳和时间的相互转换
时间戳定义为从格林威治时间 1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数. C#格式时间转时间戳Timestamp private in ...
- [CFGym101028] 2016 Al-Baath University Training Camp Contest-1
比赛链接:http://codeforces.com/gym/101028/ 由于实习,几乎没有时间刷题了.今天下午得空,断断续续做了这一套题,挺简单的. A.读完题就能出结果. /* ━━━━━┒ギ ...