W
wjj_cz
Unregistered / Unconfirmed
GUEST, unregistred user!
delphi从EXCEL读取数据为什么总是出现method 'cell' net supported by automation object?源码如下:
procedure TForm1.Button1Click(Sender: TObject);
var excelapp,myworkbooklevariant;
i,j:integer;
begin
try
excelapp:=createoleobject('excel.application');
myworkbook:=createoleobject('excel.sheet');
except
application.MessageBox('无法打开文件','',mb_ok+mb_iconstop);
exit;
end;
excelapp.visible:=true;
MyworkBook:= ExcelApp.workBooks.Open('d:/aaa.xls');
panel1.Caption:=myworkbook.cells[2,2].value;
panel2.Caption:=myworkbook.cells[2,3].value;
panel3.Caption:=myworkbook.cells[2,4].value;
end;
procedure TForm1.Button1Click(Sender: TObject);
var excelapp,myworkbooklevariant;
i,j:integer;
begin
try
excelapp:=createoleobject('excel.application');
myworkbook:=createoleobject('excel.sheet');
except
application.MessageBox('无法打开文件','',mb_ok+mb_iconstop);
exit;
end;
excelapp.visible:=true;
MyworkBook:= ExcelApp.workBooks.Open('d:/aaa.xls');
panel1.Caption:=myworkbook.cells[2,2].value;
panel2.Caption:=myworkbook.cells[2,3].value;
panel3.Caption:=myworkbook.cells[2,4].value;
end;