Forum Moderators: open

Message Too Old, No Replies

Excel Again

not working in office 2k

         

natty

11:38 am on Jul 15, 2004 (gmt 0)

10+ Year Member



hi all,

trying to output these reports to excel, passing the tables i need to request.form from the previous page.
this works on excel 97, and XP but in excel 2k it pops a little dialog saying
"Transferring"
with a progress bar named the report path..
excel fires up but the book is empty.

code is
<%
Response.ContentType = "application/vnd.ms-excel"
for each nm in request.form
response.write "<table border=""1"">" & request.form(nm) & "</table>" & "<br />"
next
%>
cant see why?!
if i comment out the contentType it happily chucks out the html.

natty

3:08 pm on Jul 15, 2004 (gmt 0)

10+ Year Member



ok this is killing me

using the script above the page generates (if i comment out the contentType) a normal table.
which is what i want, it has a tbody, trs, ths, tds..etc

If i comment out the response.write and simply put the HTML of generated table in the page pops up happily in excel2k.

however, if i use response.write of the form as above, exccel 2k refuses to show anything at all..

how can the exact same code, first generated with a response.write, not show, and the exact same, in raw HTML works fine?!?!?!?

this is driving me completely spare..
any help greatly appreciated.

RainMaker

3:26 pm on Jul 15, 2004 (gmt 0)

10+ Year Member



try clearing the buffer first...I think it's Response.Clear(); Now that I think about it...I really don't think you have to use a loop in order for excel to process it...although I have to dig up the code...if you want it..lemme know and I will get it for ya...but try the clear first :-)

natty

4:13 pm on Jul 15, 2004 (gmt 0)

10+ Year Member



hi rain,

any code that works would be great ;)

cheers,

nat

RainMaker

4:38 pm on Jul 15, 2004 (gmt 0)

10+ Year Member



Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.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);
ReportGrid.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();

this code is for a Reportgrid...and you don't neccessarily have to display it in order to load one...and doing this way maybe a lil more straight forward...hope it helps...