Jump to content
uniGUI Discussion Forums
SMARAM

Export UniDBGrid To Excel Without OLE or Excel Application

Recommended Posts

Hi,

 

As the title says, I converted a library that Mike Heydon made to export a DataSet to old format Excel file (xls) without OLE or Excel installed.

This library now converts an UniDBGrid to Excel.

 

Sample of usage. 

//  Add uses UExportExcel

procedure TMainForm.UniButton1Click(Sender: TObject);
var url, filename, reportname : String;
    exportExcel: TDataSetToExcel;
    i: integer;
begin
	reportname := 'ExcelReport';
	url := UniServerModule.LocalCacheURL+name+'.xls';
	filename := UniServerModule.NewCacheFileUrl(false, 'xls', reportname, '', url);

	exportExcel := TDataSetToExcel.Create(filename);
  exportExcel.Grid := UniDBGrid1;
  exportExcel.WriteFile;
  FreeAndNil(exportExcel);
  UniSession.SendFile(filename, reportname+'.xls');
end;

Hope it helps everyone. 

UExportExcel.zip

  • Upvote 2

Share this post


Link to post
Share on other sites

×