JAYESH A J

JAYESH A J

  • NA
  • 60
  • 8.7k

How to download datatable value in Excel.

Jan 17 2019 5:53 AM
Hi Sir,
 
When lot of time checking down load fuctions, but our side not dowl load excel file.
can you please help me.
 
currenlty creating code are below.
 
DataTable filterdt = view.ToTable(false, "Date", "src", "0 Hour", "1 Hour", "2 Hour", "3 Hour", "4 Hour", "5 Hour", "6 Hour", "7 Hour", "8 Hour", "9 Hour", "10 Hour", "11 Hour", "12 Hour", "13 Hour", "14 Hour", "15 Hour", "16 Hour", "17 Hour", "18 Hour", "19 Hour", "20 Hour", "21 Hour", "22 Hour", "23 Hour", "Total");
filterdt.TableName = "logicoofferta";
using (XLWorkbook wb = new XLWorkbook())
{
wb.Worksheets.Add(filterdt);
wb.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
wb.Style.Font.Bold = true;
Response.ClearContent();
Response.Buffer = true;
//Response.AddHeader("content-disposition", "attachment; filename=BidderReport.xls");
//Response.ContentType = "application/ms-excel";
Response.Charset = "";
StringWriter objStringWriter = new StringWriter();
// HtmlTextWriter objHtmlTextWriter = new HtmlTextWriter(objStringWriter);
// gv.RenderControl(objHtmlTextWriter);
Response.Output.Write(objStringWriter.ToString());
Response.Flush();
Response.End();
}
return View("Graph", "ExportData");
 

Answers (1)