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: ...
随机推荐
- CodeBlocks ubuntu常见问题及小技巧
1.安装完后没有快捷键的设置: http://blog.csdn.net/sjwbcb/article/details/4797785 感谢这哥,原来是包没有装全. codeblocks用ubuntu ...
- 科普:WiFi是谁申请的专利?高通吗?错!
你给Wi-Fi交过专利费吗?你知道Wi-Fi是谁申请的专利吗? 答:肯定是高通! 错! Wi-Fi技术由澳洲政府的研究机构CSIRO在90年代发明并于1996年在美国成功申请了无线网技术专利.(US ...
- 人脸识别算法准确率最终超过了人类 The Face Recognition Algorithm That Finally Outperforms Humans
Everybody has had the experience of not recognising someone they know—changes in pose, illumination ...
- PostgreSQL删除表
PostgreSQL的DROP TABLE语句是用来删除表定义及其所有相关的数据表的索引,规则,触发器和约束. 必须使用此命令时要小心,因为一旦一个表被删除表中提供的所有信息也将被永远失去了. 语法: ...
- centos chrome
在centos6.X和redhat enterprise 中安装chrome,我找了很久都不行,今天终于找到了可以用下脚本那安装: #! /bin/bash # Google Chrome Insta ...
- NDK(6)eclipse下断点调试ndk代码
Using the NDK Plugin 1. First set the path to SDK and NDK: Eclipse -> Window -> Preferences -& ...
- html5 getComputedStyle + resize 实现动态宽高度等比响应式页面设计
序:通常我们只能控制div的宽度 而不能控制高度,在响应式页面里 如果要这个div是正方形那么必须的用媒体查询在不同的分辨率下写死宽高度 今天突发奇想研究了个 用百分比来动态控制div的高度让其与宽度 ...
- BISTU-(1)-4-17-2016
A:贪心,遍历每次维护一个最便宜的价格,假如当前价格不如此前价格,就用此前价格购买当前数量的肉,每次更新最便宜的价格. #include <algorithm> #include < ...
- VIM移动
VIM移动 断断续续的使用VIM也一年了,会的始终都是那么几个命令,效率极低 前几个星期把Windows换成了Linux Mint,基本上也稳定了下来 就今晚,我已经下定决心开始新的VIM之旅,顺 ...
- iOS富文本(二)初识Text Kit
概述 Text Kit 是建立在Core Text上的文本布局系统,虽然没有Core Text那么强大的文本处理功能,但是对于大多数常见的文本布局用Text Kit能够很简单的实现,而不是用Core ...