Method 'SaveAs' not supported by automation object
var
oXL, oWB, oSheet, oRng, VArray : Variant;
SysPath:string;
begin
SysPath:=ExtractFilePath(application.exename);
Aq.Close;
Aq.SQL.Add('psp_goodtype');
Aq.Open;
while not Aq.Eof do
begin
// Start Excel and get Application Object
oXL := CreateOleObject('Excel.Application');
oXL.Visible := false;
// Get a new workbook
oWB := oXL.Workbooks.Add;
oSheet := oWB.ActiveSheet;
// Add table headers going cell by cell
……
//get the class
oXL.SaveAs(SysPath+'\'+Aq.Fields[3].AsString+'_'+Aq.Fields[4].AsString+'_'+Aq.Fields[5].AsString+'.xls');
oXL.Workbooks.Close;
oXL.Close;
Memo1.Lines.Insert(0,Aq.Fields[3].AsString+'---'+Aq.Fields[4].AsString+'---'+Aq.Fields[5].AsString);
Aq.Next;
end;
end;
运行提示Method 'SaveAs' not supported by automation object,难道Delphi操作Excel自动保存还有什么玄机?
另外读取数据库时如果我不使用fidlds[0]这样的序号来读,使用字段名应该使用哪个方法呢?请举例说明,谢谢!