摘要载入中…    请稍等…












内容载入中…    请稍等…

如长时间看不到内容,请关闭浏览器,重新打开此页!

芯友首页 应用软件 编程开发 网络硬件 资源下载 动漫音乐 精美图库 芯友论坛 视频教程 电脑技术QQ群:72845454
 ★★photoshop学友-史上最强播放器★★
 位置:编程开发>Deiphi>Deiphi数据库编程
◎→ 本类最新
asp + sqlserver 分页方法(不用
在Delphi中用拼音首字符序列来实
在Delphi中实现多重查询
用DELPHI编程访问SQL SERVER数据
加密ACCESS数据库增加安全性
加密ACCESS数据库增加安全性
文本数据导入数据库的方法
◎→相关资源
C语言入门视频教程
C#编程WinForm入门视频
Asp.net入门视频教程下载
VC++编程视频教程下载
VB窗体文章
HTML入门教程
Deiphi实例教程
Deiphi窗体文章
Deiphi数据库编程
Deiphi网络编程
Deiphi图形图象文章
Deiphi系统文件
◎→ 热门资源
droopyeyes的字符串操作函数集
ESBMaths v3.2.1 (数学公式包)
FastReport v3.07 汉化文件
注册表基本操作,简单加密
在应用程序中开关WINDOWS系统
在Delphi中使用CreateOleObject方
在Delphi中如何对注册表进行操作

用自动化往Word、Excel中输出数据库内容


日期:2008-10-20 22:06:54    来源:
   
 ·Delphi实现通用的定时自动关机程序(3) ·在Delphi中使用CreateOleObject方法对WORD文件进行操作
 ·我写的采用csv格式将数据转换为excel的函数,带有分栏功能 ·设置FTP消息和目录输出样式
 ·office,excel实例视频教程软件下载
用自动化往Word、Excel中输出数据库内容


unit OfficeForm;  

interface  

uses  
SysUtils, Windows, Messages, Classes, Graphics,  
Controls, Forms, DBCtrls, StdCtrls, DBTables,  
ExtCtrls, Mask, Db, Dialogs, Excel97, Word97,  
OleServer;  

type  
TFormOff = class(TForm)  
DBEdit3: TDBEdit;  
Label3: TLabel;  
Label2: TLabel;  
DBEdit2: TDBEdit;  
DBEdit1: TDBEdit;  
Label1: TLabel;  
DBNavigator1: TDBNavigator;  
Table1: TTable;  
DataSource1: TDataSource;  
BtnWord: TButton;  
BtnExcel: TButton;  
SaveDialog1: TSaveDialog;  
ExcelApplication1: TExcelApplication;  
WordDocument1: TWordDocument;  
procedure BtnWordClick(Sender: TObject);  
procedure BtnExcelClick(Sender: TObject);  
end;  

var  
FormOff: TFormOff;  

implementation  

{$R *.DFM}  

uses  
ComObj, ActiveX;  

procedure TFormOff.BtnWordClick(Sender: TObject);  
var  
Bookmark: TBookmark;  
RangeW: Word97.Range;  
v1: Variant;  
ov1: OleVariant;  
Row1: Word97.Row;  
begin  
WordDocument1.Activate;  
// insert title  
WordDocument1.Range.Text := 'American Capitals from ' + Table1.TableName;  
WordDocument1.Range.Font.Size := 14;  
// disable the UI  
Table1.DisableControls;  
try  
// store the current position  
Bookmark := Table1.GetBookmark;  
try  
// scan the database table  
Table1.First;  
while not Table1.EOF do  
begin  
// send the two fields  
WordDocument1.Range.InsertParagraphAfter;  
WordDocument1.Paragraphs.Last.Range.Text :=  
Table1.FieldByName ('Name').AsString + #9 +  
Table1.FieldByName ('Capital').AsString;  
Table1.Next;  
end;  
finally  
// go back to the bookmark and destroy it  
Table1.GotoBookmark (Bookmark);  
Table1.FreeBookmark (Bookmark);  
end;  
finally  
// re-enable the controls  
Table1.EnableControls;  
end;  
RangeW := WordDocument1.Content;  
v1 := RangeW;  
v1.ConvertToTable (#9, 19, 2);  
Row1 := WordDocument1.Tables.Item(1).Rows.Get_First;  
Row1.Range.Bold := 1;  
Row1.Range.Font.Size := 30;  
Row1.Range.InsertParagraphAfter;  
ov1 := ' ';  
Row1.ConvertToText (ov1);  
end;  

procedure TFormOff.BtnExcelClick(Sender: TObject);  
var  
RangeE: Excel97.Range;  
I, Row: Integer;  
Bookmark: TBookmarkStr;  
begin  
// create and show  
ExcelApplication1.Visible [0] := True;  
ExcelApplication1.Workbooks.Add (NULL, 0);  
// fill is the first row with field titles  
RangeE := ExcelApplication1.ActiveCell;  
for I := 0 to Table1.Fields.Count - 1 do  
begin  
RangeE.Value := Table1.Fields [I].DisplayLabel;  
RangeE := RangeE.Next;  
end;  
// add field data in following rows  
Table1.DisableControls;  
try  
Bookmark := Table1.Bookmark;  
try  
Table1.First;  
Row := 2;  
while not Table1.EOF do  
begin  
RangeE := ExcelApplication1.Range ['A' + IntToStr (Row),  
'A' + IntToStr (Row)];  
for I := 0 to Table1.Fields.Count - 1 do  
begin  
RangeE.Value := Table1.Fields [I].AsString;  
RangeE := RangeE.Next;  
end;  
Table1.Next;  
Inc (Row);  
end;  
finally  
Table1.Bookmark := Bookmark;  
end;  
finally  
Table1.EnableControls;  
end;  
// format the section  
RangeE := ExcelApplication1.Range ['A1', 'E' + IntToStr (Row - 1)];  
RangeE.AutoFormat (3, NULL, NULL, NULL, NULL, NULL, NULL);  
end;  

initialization  
CoInitialize (nil);  
end.

 [1]

Delphi实现通用的定时自动关机程序(2)

将WORD中的内容转化为曲线

工作中学习Excel

Excel 2000单条记录输出3板斧

--->QQ自动登录器 V1.6.1.0515┊可以支持高强度密码加密算法┊简体中文绿色免费版
--->一流QQ堂多开 刷分器 V7.7┊永不掉线、掉线会自动重登录┊简体中文绿色特别版
--->QQ空间人气精灵 V3.61┊自动模拟无数真实用户访问QQ空间┊简体中文绿色免费版
--->VDownloader V0.4┊只需要输入影片的链接地址、自动为你下载┊英文绿色特别版
--->PicaLoader V1.46┊网络抓图好帮手、全自动化支持多线程下载┊汉化绿色特别
Tags:  自动 Word Excel 输出
{$enumber$}
芯友网版权所有 1999-2006 | 著作权与商标声明 | 法律声明 | 服务条款 | 隐私声明 | 联系我们