我编写delphi控制execl时出现如下问题,请各位dfw帮忙,谢谢!(10分)

H

hbgrape

Unregistered / Unconfirmed
GUEST, unregistred user!
程序如下:
unit cexecl;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleServer, Excel2000;

type
TForm1 = class(TForm)
ExcelWorksheet1: TExcelWorksheet;
ExcelWorkbook1: TExcelWorkbook;
ExcelApplication1: TExcelApplication;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
{$TYPEDADDRESS OFF}

procedure TForm1.Button1Click(Sender: TObject);
begin
ExcelApplication1.Connect;
ExcelApplication1.Visible[0]:=True;
ExcelApplication1.Caption := '应用程序调用 Microsoft Excel';
//ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Add(EmptyParam,0));
ExcelApplication1.Workbooks.Open ('c:/a.xls',
EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,0);
ExcelApplication1.WorkSheets[2].Activate;
ExcelApplication1.Cells(1,4).Value := '第一行第四列';
//if not ExcelApplication1.ActiveWorkBook.Saved then
ExcelApplication1.ActiveSheet.PrintPreview;
ExcelApplication1.SaveAs('C:/Excel/Demo1.xls');
ExcelApplication1.WorkBooks.Close;
ExcelApplication1.Quit;
ExcelApplication1.Disconnect;

end;

end.
提示错误如下:
Error] cexecl.pas(40): Undeclared identifier: 'Activate'
[Error] cexecl.pas(41): Missing operator or semicolon
[Error] cexecl.pas(43): Undeclared identifier: 'PrintPreview'
[Error] cexecl.pas(44): Undeclared identifier: 'SaveAs'
[Error] cexecl.pas(45): Not enough actual parameters
[Fatal Error] execl.dpr(5): Could not compile used unit 'cexecl.pas'
而且uses中的execl2000在查找时说没有execl2000.pas,why?
我才开始学delphi,标准菜鸟,别笑我啊!
请帮忙!谢谢!
初来,没多少分,先给10分,如果不满意我再加
 
use excel2000;

在资源管理器中搜索excel2000,记录其路径
在菜单/project/options/directory ...
search path中加入之
 
use Comobj;

//this is very important!!!
 
我搜索了全部硬盘没有找到啊!是和execl2000有关吗?
谢谢!
 
那就uses comobj,excel97试试
 
use Comobj;
加上还是一样的。
 
那就uses comobj,excel97试试
也一样。
 
execl97和execl2000在我的机子上都没有。?
 
我的C:/Program Files/Borland/Delphi6/Projects目录下没有options目录啊!
 
在Delphi6/ocx/servers中
 
在你的机器里搜索
excel97 和excel2000
 
找到execl2000了,但编译还是出错。
提示错误如下:
Error] cexecl.pas(40): Undeclared identifier: 'Activate'
[Error] cexecl.pas(41): Missing operator or semicolon
[Error] cexecl.pas(43): Undeclared identifier: 'PrintPreview'
[Error] cexecl.pas(44): Undeclared identifier: 'SaveAs'
[Error] cexecl.pas(45): Not enough actual parameters
[Fatal Error] execl.dpr(5): Could not compile used unit 'cexecl.pas'
 
我已解决了,谢谢大家。
人人有分,皆大欢喜。
 
怎么解决的?能告诉我吗,我也出了相同的问题。
谢谢。
 
顶部