Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Null Values in datagrid excel export

Status
Not open for further replies.

justTryingToCode

Programmer
Nov 14, 2006
13
US
Hi all experts:

I am trying to capture nulls and keep them as nulls from a dataset to a datagrid to a xls export using httpResponse. The returned .xls file has blanks where the nulls should be.
Any help would be greatly appreciated. Here is the current code snippet:

string in_params = start + "|" + end;
reports rp = new reports(connString);
rp.get_report_details_for_render(5);
DataSet ds = new DataSet();
ds = update_property_page_specific_data(rp.get_report_dataSet_results(in_params));
DataGrid dg = new DataGrid();
dg.DataSource = ds.Tables[0];
dg.DataBind();

string strExportFile = "extract_" + DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss") + ".xls";


Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=" + strExportFile);
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
dg.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();

Thanks in advance,
Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top