I am exporting a datatable to Excel. The syntax works, but the data in column E is so much it formats the column width to around 80 height. How can I format the output so that it does not auto-set the row height to 80? This is my current syntax:

public void EXprt(DataTable dataTable)
 {
string excelname = "Book1.xls";
StringWriter tw = new System.IO.StringWriter();
HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
DataGrid dgGrid = new DataGrid();
dgGrid.DataSource = dataTable;
dgGrid.DataBind();
dgGrid.RenderControl(hw);
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; excelname=" + excelname + ""); 
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}

Related posts

Recent Viewed