tags:

views:

33

answers:

1

hello,

using asp.net 3.5 I am trying to generate a formatted excel spreadsheet and the way i am doing it is:

1.Format the excel sheet with data 2.Save it as an xml spreadhseet 3.View it in notepad/textpad and remove the "data" from the xml and have a content holder such as "DYNAMICDATA" 4.Build dynamic xml for data and replace the "DYNAMICDATA" place holder with this fresh data. 5.have all this in a stringbuilder

I m stuck here, I want to be able to Response.Write(stringbuilder) but it does not work, I have used the appropriate MIME types etc.

However Response.TransmitFile() works when i just transmit an xml spreadsheet to browser. but Response.TransmitFile() takes a file as an argument, I can create a temp file write the created xml and then transmit but that just seems like a heavy overhead.

Is there a way i can without creating a file, just transmitXml() using the stringbuilder contents and let the user save the spreadsheet.

thank you,

A: 

Maybe this will help you. put in your code:

Response.AppendHeader("Content-Type", "application/ms-excel");
Response.AppendHeader("Content-disposition", "attachment; filename=Rep.xls");
Response.Charset = "";

Then use your:

Response.Write(stringbuilder);

Don't forget:

Response.End();
adinas