社区
Delphi
帖子详情
关于d5中TExcelWorkApplication,TExcelworkbook等的用法
oddstar
2000-03-13 11:19:00
我想用TExcelWorkApplication,TExCelWorkBook,TExcelSheet把我新建的一个book1.xls中的所有sheet中的所有cell的内容读出来,但总未成功,请哪位高手指点,
最好附上源程序.
...全文
67
回复
打赏
收藏
关于d5中TExcelWorkApplication,TExcelworkbook等的用法
我想用TExcelWorkApplication,TExCelWorkBook,TExcelSheet把我新建的一个book1.xls中的所有sheet中的所有cell的内容读出来,但总未成功,请哪位高手指点, 最好附上源程序.
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ex
cel
control by delphi
//About my self ex
cel
control ..... study data // for your information... unit toxls5butt; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Ex
cel
2000, OleServer; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; CheckBox1: TCheckBox; Button5: TButton; SaveDialog1: TSaveDialog; OpenDialog1: TOpenDialog; // Ex
cel
Work
sheet1:
TEx
cel
Work
sheet; // Ex
cel
OLEObject1:
TEx
cel
OLEObject; // Ex
cel
Work
book
1:
TEx
cel
Work
book
; // Ex
cel
Application
1:
TEx
cel
Application
; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); private v:variant; sheet:variant; { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation { *.dfm} uses comobj; procedure TForm1.Button1Click(Sender: TObject); begin try V:=createoleobject(‘ex
cel
.
application
‘); v.visible:=checkbox1.Checked; v.
work
book
s.add; v.
work
book
s[1].
work
sheets[1].name:=‘good‘; sheet:=v.
work
book
s[1].
work
sheets[1]; sheet.
cel
ls[3,1]:=‘31‘; sheet.
cel
ls[2,1]:=‘21‘; sheet.
cel
ls[1.5]:=‘15‘; sheet.
cel
ls[2,2]:=‘22‘; v.
work
book
s[1].
work
sheets[2].name:=‘love‘; sheet:=v.
work
book
s[1].
work
sheets[2]; sheet.
cel
ls[3,4]:=‘34hello‘; // sheet:=v.
work
book
s[1].
work
sheets[‘helloaaa‘]; except showmessage(‘ex
cel
init load error, not ex
cel
or other error!‘); v.displayalerts:=false; v.quit; exit; end;
application
.Restore;
application
.BringToFront; end; procedure TForm1.Button2Click(Sender: TObject); begin if opendialog1.Execute then begin try V:=createoleobject(‘ex
cel
.
application
‘); v.visible:=checkbox1.Checked; v.
work
book
s.open(opendialog1.FileName); except showmessage(‘ex
cel
init error, not ex
cel
or other error, try again‘); v.displayalerts:=false; v.quit; exit; end;
application
.Restore;
application
.BringToFront; end; end; procedure TForm1.Button3Click(Sender: TObject); begin try if not varisempty(v) then begin v.DisplayAlert:=true; v.
work
book
s[1].close(true,‘c:untitled.xls‘); v.
work
book
s[1].close(true,‘*.xls‘); v.quit; end; finally close; end; end; procedure TForm1.Button4Click(Sender: TObject); begin if opendialog1.Execute then begin try v:=createoleObject(‘ex
cel
.
application
‘); v.visible:=checkbox1.Checked; v.
work
book
s.open(opendialog1.FileName); sheet:=v.
work
book
s[1].
work
sheet[1]; sheet.pagesetup.printtitlerows:=‘$1:$3‘; //page head sheet.pagesetup.printtitlecolumns:=‘‘; sheet.pagesetup.leftfooter:=‘Noted: PageHead‘+‘sum total&N page ‘+‘--No.&Page‘; //pagehead sheet.pagesetup.leftmargin:=30; //偞离?擒 Sheet.PageSetup.RightMargin := 30; Sheet.PageSetup.TopMargin := 30; Sheet.PageSetup.BottomMargin := 50; Sheet.PageSetup.PrintQuality := 300; //賤昴僅(跦?荂桶復隅) Sheet.PageSetup.CenterHorizontally := True;//岆瘁阨懈笢 Sheet.PageSetup.CenterVertically := True; //岆瘁晶眻懈笢 Sheet.PageSetup.Orientation := 2; //砃蹈荂 Sheet.PageSetup.Draft := False; //準翌詨耀宒 Sheet.PageSetup.FirstPageNumber := xlAutomatic; Sheet.PageSetup.BlackAndWhite := false; //窪啞詨 Sheet.PageSetup.Zoom := 100; //窺溫 sheet.PrintPreView; //蹈荂蕼罜 except Showmessage(‘initiale error ㄛnot Ex
cel
ㄛor other error ˙try again!‘); v.DisplayAlerts := false; v.Quit; // finally exit; end; end; end; end.
TEx
cel
Application
,
TEx
cel
Work
sheet,
TEx
cel
Work
book
用法
最近用delphi写一个查询数据库并自动生成ex
cel
报表的工具,发现网上很多关于delphi操作ex
cel
的介绍都是不正确的。下面就介绍一下在delphi 7
中
操作ex
cel
的一些基本方法: 把
TEx
cel
Application
,
TEx
cel
Work
sheet,
TEx
cel
Work
book
拉到窗体上。 1.取得与ex
cel
引擎的连接 try...
D7
中
使用
D5
D6的控件
其实,我们在原来版本如
D5
、D6
中
使用的控件如Quickrep,FastNet等,在D7
中
仍然是保留的。只是Delphi没有将他们默认的安装到组件面版
中
来。这些控件包全部保存在Delphi目录的bin下,文件扩展名为.bpl(共将近60个)。安装这些包的方法很简单,只需点击菜单"component---->Install Packages...",然后使用"ADD"选择需要的包就可以了。下面就其
中
Delphi 7操作Ex
cel
的文章参考
用Delphi 7自己的组件的:
TEx
cel
Application
,
TEx
cel
Work
sheet,
TEx
cel
Work
book
用法
Delphi自带控件操作Ex
cel
Delphi7
中
使用低版本D6
D5
的控件
其实,我们在原来版本如
D5
、D6
中
使用的控件如Quickrep,FastNet等,在D7
中
仍然是保留的。只是Delphi没有将他们默认的安装到组件面版
中
来。这些控件包全部保存在Delphi目录的bin下,文件扩展名为.bpl(共将近60个)。安装这些包的方法很简单,只需点击菜单"component---->Install Packages...",然后使用"ADD"选择需要的包就可以了。下面就
Delphi
5,388
社区成员
262,730
社区内容
发帖
与我相关
我的任务
Delphi
Delphi 开发及应用
复制链接
扫一扫
分享
社区描述
Delphi 开发及应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章