delphi 中定义一个variant变量调用excel,excelid.后无提示信息,很郁闷?
首先在Uses处加上ComObjprocedureTForm1.Button1Click(Sender:TObject);varh,k:integer;Excelid:O...
首先在Uses处加上ComObj
procedure TForm1.Button1Click(Sender: TObject);
var h,k:integer;
Excelid: OleVariant;
s: string;
begin
try
Excelid := CreateOLEObject('Excel.Application');
except
Application.MessageBox('Excel没有安装!', '提示信息', MB_OK+MB_ICONASTERISK+MB_DEFBUTTON1+MB_APPLMODAL);
Exit;
end;
try
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from jj_department');
ADOQuery1.Open;
k:=ADOQuery1.RecordCount;
Excelid.Visible := True; 展开
procedure TForm1.Button1Click(Sender: TObject);
var h,k:integer;
Excelid: OleVariant;
s: string;
begin
try
Excelid := CreateOLEObject('Excel.Application');
except
Application.MessageBox('Excel没有安装!', '提示信息', MB_OK+MB_ICONASTERISK+MB_DEFBUTTON1+MB_APPLMODAL);
Exit;
end;
try
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from jj_department');
ADOQuery1.Open;
k:=ADOQuery1.RecordCount;
Excelid.Visible := True; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询