Cell Data too Large When converting DataGrid to Excel

  • Thread starter Thread starter hangar18
  • Start date Start date
H

hangar18

Hi,
We are using the following code to convert a datagrid to an excel
output. This works fine except that the issue is we get this error
message "Cell Data too Large".
How can we resolve this. Appreciate the help.

The code is as follows:

ReportFacade<DataSet> reportFacade = new ReportFacade<DataSet>();
DataSet ds = null;
ds = reportFacade.GetExcelReportData(excelReportEntity);

GridView grd = new GridView();
//System.Drawing.Color colour = new
System.Drawing.Color();
//colour = System.Drawing.Color.Gray;
//grd.HeaderRow.BackColor = colour;

grd.DataSource = ds;
grd.DataBind();
current.Response.Clear();
current.Response.AddHeader("content-disposition",
string.Format("attachment; filename={0}",
excelReportEntity.FileName));
current.Response.ContentType = "application/ms-excel";

//Response.Charset = "";
//this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new
System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new
System.Web.UI.HtmlTextWriter(oStringWriter);
this.ClearControls(grd);
//oHtmlTextWriter =
oHtmlTextWriter.ToString().Replace("<th ", "<th
x:autofilter=''''all''''");
grd.RenderControl(oHtmlTextWriter);
string s = oStringWriter.ToString();

s = header + s + "</HTML>";



s = s.Replace("<th ", "<th x:autofilter='all' ");

current.Response.Write(s);
current.Response.Flush();
current.Response.End();
 
Back
Top