天
天国之时
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure Tfselectresult.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
action := cafree;
end;
procedure Tfselectresult.BitBtn1Click(Sender: TObject);
var xlapp : variant;
n : integer;
ARecordSet : _recordset;
ds:TDataSet;
begin
xlapp := createoleobject('excel.application');
savedialog1.Filter := 'EXCEL工作表(*.xls)|*.xls';
if savedialog1.Execute then xlapp.workbooks.add(savedialog1.FileName)
try
for n := 1 to dbgrid1.Columns.Count do
xlapp.worksheets[1].cells[1,n] := dbgrid1.Columns.Items[n-1].FieldName;
ds:=TADODataSet.Create(self);
dbgrid1.DataSource.DataSet := TCustomADODataSet(ds);
TCustomADODataSet(ds).Recordset:=ARecordSet;
xlapp.worksheets[1].cells[2,1].CopyFromRecordset(ARecordSet);
finally
xlapp.save;
xlapp.quit
end;
end;
系统提示xlapp.worksheets[1].cells[2,1].CopyFromRecordset(ARecordSet);参数不正确
有没有人用这种方法导出
var Action: TCloseAction);
begin
action := cafree;
end;
procedure Tfselectresult.BitBtn1Click(Sender: TObject);
var xlapp : variant;
n : integer;
ARecordSet : _recordset;
ds:TDataSet;
begin
xlapp := createoleobject('excel.application');
savedialog1.Filter := 'EXCEL工作表(*.xls)|*.xls';
if savedialog1.Execute then xlapp.workbooks.add(savedialog1.FileName)
try
for n := 1 to dbgrid1.Columns.Count do
xlapp.worksheets[1].cells[1,n] := dbgrid1.Columns.Items[n-1].FieldName;
ds:=TADODataSet.Create(self);
dbgrid1.DataSource.DataSet := TCustomADODataSet(ds);
TCustomADODataSet(ds).Recordset:=ARecordSet;
xlapp.worksheets[1].cells[2,1].CopyFromRecordset(ARecordSet);
finally
xlapp.save;
xlapp.quit
end;
end;
系统提示xlapp.worksheets[1].cells[2,1].CopyFromRecordset(ARecordSet);参数不正确
有没有人用这种方法导出