procedure TForm1.Button1Click(Sender: TObject); var excelApp: Variant; row, col: integer; begin excelApp := CreateOleObject('Excel.Application');// uses ComObj excelApp.WorkBooks.Add; excelApp.Visible := True; for col := 1 to self.ADOTable1.FieldCount do begin excelApp.Cells[1, col].Value := self.ADOTable1.Fields[col - 1].FieldName; end; for row := 1 to self.ADOTable1.RecordCount do begin for col := 1 to self.ADOTable1.FieldCount do begin excelApp.Cells[row + 1, col].Value := Self.ADOTable1.Fields[col - 1].AsString; end; self.ADOTable1.Next; end; excelApp := UnAssigned; end;
提示这样的错误怎么办啊? [Error] Unit_ygda.pas(307): Undeclared identifier: 'CreateOleObject' [Fatal Error] blocway.dpr(64): Could not compile used unit 'Unit_ygda.pas'
var
excelApp: Variant;
row, col: integer;
begin
excelApp := CreateOleObject('Excel.Application');// uses ComObj
excelApp.WorkBooks.Add;
excelApp.Visible := True;
for col := 1 to self.ADOTable1.FieldCount do
begin
excelApp.Cells[1, col].Value := self.ADOTable1.Fields[col - 1].FieldName;
end;
for row := 1 to self.ADOTable1.RecordCount do
begin
for col := 1 to self.ADOTable1.FieldCount do
begin
excelApp.Cells[row + 1, col].Value := Self.ADOTable1.Fields[col - 1].AsString;
end;
self.ADOTable1.Next;
end;
excelApp := UnAssigned;
end;
[Error] Unit_ygda.pas(307): Undeclared identifier: 'CreateOleObject'
[Fatal Error] blocway.dpr(64): Could not compile used unit 'Unit_ygda.pas'
excelApp := CreateOleObject('Excel.Application');// uses ComObj