J
JawzX01
Hello All,
First, thank you for any help you can provide.
I'm trying to do a simple export to excel. I've used the classic
code that is all over the internet, and of course it worked without a
problem.
The problem is that I want to add text above the data grid in the
excel sheet. The text already exists on the web page in various panels
(there is different text depending on the parameters of the datagrid
report). But, every attempt to accomplish this, results in HTML being
rendered (for both the text and the data grid). Again, the data grid
exports correctly without the additional text.
Any help would be appreciated, even a references to an article on the
internet.
--- The code I'm using --
//Filling the data grid is handled else where...
//
//export to excel
Response.Clear();
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
//Response.ContentType = "application/vnd.xls";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new
System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new
System.Web.UI.HtmlTextWriter(oStringWriter);
dgReport.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
----
Here are a couple things that I've tried. Just before the
dgReport.RenderControl(oHtmlTextWriter), I've inserted
rptText.RenderControl(oHtmlTextWriter) -- this "worked" but the HTML
formating didn't work, all of the HTML was visible in excel like I was
looking at the page in notepad.
Additionally, I've tried to export the entire page to excel, but then
the headers (and filter bar) show up in it. My attempt to hide all of
the headers (and the filter bar) didn't work... Even though the
visible property (wrapped around the filter bar) was set to false, it
still rendered in excel.
I hope this is enough information, but if more is needed ask.
Thank you & Regards,
Frank
First, thank you for any help you can provide.
I'm trying to do a simple export to excel. I've used the classic
code that is all over the internet, and of course it worked without a
problem.
The problem is that I want to add text above the data grid in the
excel sheet. The text already exists on the web page in various panels
(there is different text depending on the parameters of the datagrid
report). But, every attempt to accomplish this, results in HTML being
rendered (for both the text and the data grid). Again, the data grid
exports correctly without the additional text.
Any help would be appreciated, even a references to an article on the
internet.
--- The code I'm using --
//Filling the data grid is handled else where...
//
//export to excel
Response.Clear();
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
//Response.ContentType = "application/vnd.xls";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new
System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new
System.Web.UI.HtmlTextWriter(oStringWriter);
dgReport.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
----
Here are a couple things that I've tried. Just before the
dgReport.RenderControl(oHtmlTextWriter), I've inserted
rptText.RenderControl(oHtmlTextWriter) -- this "worked" but the HTML
formating didn't work, all of the HTML was visible in excel like I was
looking at the page in notepad.
Additionally, I've tried to export the entire page to excel, but then
the headers (and filter bar) show up in it. My attempt to hide all of
the headers (and the filter bar) didn't work... Even though the
visible property (wrapped around the filter bar) was set to false, it
still rendered in excel.
I hope this is enough information, but if more is needed ask.
Thank you & Regards,
Frank