Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export data from dataset to excel

I am trying to export data from dataset to excel and save it directly to a given path without giving me the option to open,save or cancel.

like image 649
creator Avatar asked Apr 26 '11 12:04

creator


2 Answers

Using ExcelLibrary this is a one liner ...

DataSet myDataSet;
... populate data set ...
ExcelLibrary.DataSetHelper.CreateWorkbook("MyExcelFile.xls", myDataSet);

See also Create Excel (.XLS and .XLSX) file from C#

like image 60
Tony O'Hagan Avatar answered Oct 07 '22 23:10

Tony O'Hagan


This C# Excel library can also be used to export the dataset. More details about how to export can be found here.

ExcelDocument xls = new ExcelDocument();
xls.easy_WriteXLSFile_FromDataSet("ExcelFile.xls", dataset, 
                 new ExcelAutoFormat(Styles.AUTOFORMAT_EASYXLS1), "Sheet Name");
like image 29
alex.pulver Avatar answered Oct 07 '22 23:10

alex.pulver