2 problems when exporting to excel HELP!!!

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.
 
K

Kevin Spencer

Thanks! I was really worried!

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top