Monday, 26 June 2017

Export DataSet To Excel in MVC

NameSpace :
using System.Web.Hosting;
using ClosedXML.Excel;

Code  :

        private void ExportDataSetToExcel(DataSet ds, String excelName)

            string path = HostingEnvironment.MapPath("~/FolderName/");
            if (!Directory.Exists(path))
            path = path + excelName;
            using (XLWorkbook wb = new XLWorkbook())
                wb.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                wb.Style.Font.Bold = true;
                wb.SaveAs(path, false);


DataSet objds = new Dataset();
ExportDataSetToExcel(objds, "FileName.xlsx");

1 comment:

Track your Facebook login attempt

Facebook provides a feature which allows you to see all active sessions from different devices and apps together with the date it was last...