我的OLE在创建的时候就遇到了问题了:代码如下:unit Unit2;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Grids, DBGrids, Db, DBTables,OleServer,Excel97;type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
XLApp:Variant; /////////////////////定义
public
{ Public declarations }
end;var
Form1: TForm1;implementation
uses ComObj;
{$R *.DFM}procedure TForm1.BitBtn1Click(Sender: TObject);
var
i,j,k:integer;
Range1:Variant;
begin
Table1.Close;
Table1.Open;
j:=Table1.RecordCount;
if j>0 then
begin
k:=j+1;
XLApp.CreateOleObject('Excel.Application');**********************************************************************
Variant does not reference an automation object! ????????
********************************************************************** XLApp.visible:=True;
XLApp.Application.caption:='工作量统计';
XLApp.Workbooks.add(xlWBatWorkSheet);
XLApp.Workbooks[1].WorkSheets[1].name:='工作量统计';
Range1:=XLApp.Workbooks[1].WorkSheets['工作量统计'].Range['A1:C'+inttostr(k)];
Range1.Borders.LinesStyle:=xlContinuous;
XLApp.Range('A1'):='N';
XLApp.Range('B1'):='C';
for i:=2 to j+1 do
begin
XLApp.cells[i,1]:=IntToStr(i-1);
XLApp.cells[i,2]:=Table1.Fields[0].AsString ;
XLApp.cells[i,3]:=Table1.Fields[1].AsString ;
Table1.Next;
end;
XLApp.quit;
end;end;end.
麻烦各位帮看看
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Grids, DBGrids, Db, DBTables,OleServer,Excel97;type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
XLApp:Variant; /////////////////////定义
public
{ Public declarations }
end;var
Form1: TForm1;implementation
uses ComObj;
{$R *.DFM}procedure TForm1.BitBtn1Click(Sender: TObject);
var
i,j,k:integer;
Range1:Variant;
begin
Table1.Close;
Table1.Open;
j:=Table1.RecordCount;
if j>0 then
begin
k:=j+1;
XLApp.CreateOleObject('Excel.Application');**********************************************************************
Variant does not reference an automation object! ????????
********************************************************************** XLApp.visible:=True;
XLApp.Application.caption:='工作量统计';
XLApp.Workbooks.add(xlWBatWorkSheet);
XLApp.Workbooks[1].WorkSheets[1].name:='工作量统计';
Range1:=XLApp.Workbooks[1].WorkSheets['工作量统计'].Range['A1:C'+inttostr(k)];
Range1.Borders.LinesStyle:=xlContinuous;
XLApp.Range('A1'):='N';
XLApp.Range('B1'):='C';
for i:=2 to j+1 do
begin
XLApp.cells[i,1]:=IntToStr(i-1);
XLApp.cells[i,2]:=Table1.Fields[0].AsString ;
XLApp.cells[i,3]:=Table1.Fields[1].AsString ;
Table1.Next;
end;
XLApp.quit;
end;end;end.
麻烦各位帮看看
解决方案 »
- 帮帮忙啊...
- 关于ppt问题
- 如何把数据插入一个不与数据库相联的本地记录集中?
- 用datetimepicker插入日期记录到数据库遇到的一个奇怪问题.
- ★★★怎么做透明树枝控件?★★★
- 介绍各地软件公司情况的红黑榜网站已做好,想转工的网友不能错过。
- 准备学习Delphi,请各位大虾介绍一些学习经验!
- 请问谁知道Venus6 For D6的 s/n?
- 哪位高手能解释一下Source和Sender、Drap-and-Drop和Drag-and-Dock的区别,最好有例子!TKS!
- 一个很简单的问题(关于SendMessage的)
- 如何获取RASAPI32.DLL的声明函数
- 安装问题,十万火急!!!!!
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Grids, DBGrids, Db, DBTables,OleServer,Excel97;type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
XLApp:Variant;implementation
uses ComObj;
{$R *.DFM}
试试!
to:WWWWA(aaaa)
用控件是可以的!谢谢!
我确实是 先安装的DELPHI,然后再安装的OFFICE
那为什么用控件的时候行呢?
有点怀疑
有点怀疑
用控件行是因为这个控件是由OFFICE来注册的,而不是由DELPHI注册的