# open Excel files with ASP in C#



## Gheatza (Oct 7, 2008)

Hello ,

i'm sending a stream of data from the server to the client. When the stream reaches the client, instead of displaying the stream directly into the browser,it forces the opening of the "Download file dialog" . The stream is in excel format.

Everything works fine , the dialog appears, i press the open button , excel starts and the desired content appears.

But now i want to send that stream again, the dialog again appears, but when i press Open button, i would expect a new Excel opens with the desired information, without closing the old Excel. 

How can i solve this?
I am using Win XP, excel 2007 , IE 7, .NET 2005.

This is the code:

HttpResponse response = HttpContext.Current.Response;
response.ContentType = "application/vnd.openxmlformats- 
officedocument.spreadsheetml.sheet";
response.AddHeader("Content-Disposition", "inline; 
filename=AlarmHistory.xls");
response.Clear();
objStreamWriter = new StreamWriter(response.OutputStream, new 
UnicodeEncoding());

.... fill the stream with data....

objStreamWriter.WriteLine(); 
objStreamWriter.Flush();
response.End();


Thanks


----------

