I have field called "Comments" in my DataTable which has few records more than 255 characters.When we export the DataTable to Excel using the below code, the data is pushed into Excel but the Comments field record which has more than 255 characters overlaps other cells in Excel and the next column record is pushed to next row.
Code:
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=XXXXXX.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
foreach (DataRow dr in dt.Rows){
tab = "";
for (int i = 0; i < dt.Columns.Count; i++){
Response.Write(tab + dr[i].ToString());
tab = "\t";
}
Response.Write("\n");
}
Response.End();
Can you guys please help