Export data set into Excel using Closed XML   Leave a comment

Below is the simple code example to export the DataSet into an Excel using ClosedXML dll.

private static void ExportDataSet(DataSet ds, string destination)
          var workbook = new ClosedXML.Excel.XLWorkbook();
          foreach (DataTable dt in ds.Tables) {
                  var worksheet = workbook.Worksheets.Add(dt.TableName);
                  worksheet.Cell(1, 1).InsertTable(dt);

Posted October 16, 2014 by Izharuddin Shaikh in C#

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: