W
Wee Bubba
i am using this code to export my page to excel:
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
myDataList.RenderControl(hw);
Response.Write(sw.ToString());
Response.End();
Q1. my excel file is still showing a link button from my .aspx page. i
thought the line 'myDataList.RenderControl(hw);' meant that only the
dataList would be rendered and therefore exported to excel. how can i
export only the dataList please?
Q2. my site is protected by forms authentication in Web.Config which
means a user gets thrown out to a login page if they are not
authenticated. if i place my export to excel page within my secure
directory then when i click to export my login page appears within
excel and not the report that i was expecting. i presume this is
because i am messing with the headers? can anyone offer any help
please on how i can get around this? i know this is the problem
because if i place my pafge outside the secure directory it works.
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
myDataList.RenderControl(hw);
Response.Write(sw.ToString());
Response.End();
Q1. my excel file is still showing a link button from my .aspx page. i
thought the line 'myDataList.RenderControl(hw);' meant that only the
dataList would be rendered and therefore exported to excel. how can i
export only the dataList please?
Q2. my site is protected by forms authentication in Web.Config which
means a user gets thrown out to a login page if they are not
authenticated. if i place my export to excel page within my secure
directory then when i click to export my login page appears within
excel and not the report that i was expecting. i presume this is
because i am messing with the headers? can anyone offer any help
please on how i can get around this? i know this is the problem
because if i place my pafge outside the secure directory it works.