nativeexcel数据集导出excel
uses Dataset2Excel;
procedure Tfdm.exportXLS(dataset: TDataSet);
var
xls: TDataset2Excel;
sd: TSaveDialog;
begin
if dataset = nil then
Exit;
sd := TSaveDialog.Create(nil);
sd.Filter := 'xls|*.xls';
sd.FileName := '1.xls';
if sd.Execute then
begin
xls := TDataset2Excel.Create(nil);
xls.Dataset := dataset;
xls.WorksheetName := '1';
xls.SaveDatasetAs(sd.FileName);
xls.Workbook := nil;
xls.Free;
end;
sd.Free;
end;