473,520 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Internet Explorer unable to read Excel stream

I want to export a datagrid to Excel. Here is the code:

[after datagrid databind]
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition",
"attachment;filename=FileName.xls");
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.No Cache);
System.IO.StringWriter stringWrite = new
System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new
HtmlTextWriter(stringWrite);
DataGrid1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
When I open the page with Internet Explorer I get this:
Internet Explorer cannot download [file name] from [server name]
Internet Explorer was not able to open this Internet site. The
requested site is either unavailable or cannot be found. Please try
again later.
The funny thing: it works with Firefox - no problems at all.
Mime types on IIS are ok.
Feb 20 '08 #1
1 3089
You might have to add the ContentLength header.

PS: Are you using it with https? Some IE versions had a bug with https and
content-disposition tag. Google it.

George.
"Christian W Larsen" <cw*@colon.dkwrote in message
news:80**********************************@i29g2000 prf.googlegroups.com...
>I want to export a datagrid to Excel. Here is the code:

[after datagrid databind]
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition",
"attachment;filename=FileName.xls");
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.No Cache);
System.IO.StringWriter stringWrite = new
System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new
HtmlTextWriter(stringWrite);
DataGrid1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
When I open the page with Internet Explorer I get this:
Internet Explorer cannot download [file name] from [server name]
Internet Explorer was not able to open this Internet site. The
requested site is either unavailable or cannot be found. Please try
again later.
The funny thing: it works with Firefox - no problems at all.
Mime types on IIS are ok.

Feb 21 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1622
by: John Jonsson | last post by:
Hello! I have Visual Studio .NET Pro 2003 installed and when I tried to run an ASP.Net Web Service Project that I created I get following error: Cannot start debugging. Unable to find Microsoft Internet Explorer When I for an example choose Start Page - Online Resources - XML Web Services the following message is shown: This feature...
2
2563
by: Neil | last post by:
Hi I'm rendering my datagrid to a HTML stream with a .xls extension to open in Excel however it opens in the browser. Is there a way to programatically force it to open Excel? I know you can configure a setting in windows explorer to do this but i want to do this without any client interaction Thanks
0
789
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
3
14033
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
28
3553
by: Neo Geshel | last post by:
NOTE: PAST EXPERIENCE HAS SHOWN ME THAT MANY ON USENET FAIL TO READ ARTICLES PROPERLY PRIOR TO ANSWERING. I AM LOOKING FOR VERY SPECIFIC INFORMATION, THEREFORE PLEASE READ AND UNDERSTAND THOROUGHLY BEFORE RESPONDING; OR ASK QUESTIONS TO CLARIFY. I *WILL* APPRECIATE ANY CONSTRUCTIVE REPLY. Greetings! I am in the process of creating a...
1
4462
by: =?Utf-8?B?aHV3NTM=?= | last post by:
I use vista and internet explorer 7 with a Hp 1210 printer. The system has worked fine, but I have now discovered that I am unable to print from the browser. The page does appear in the preview, but when I press the print button nothing happens. I have gone into tools, internet options, security and unticked enable protected mode, the preview...
0
2893
by: Christian W Larsen | last post by:
I want to export a datagrid to Excel. Here is the code: Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=FileName.xls"); Response.ContentType = "application/vnd.ms-excel";
2
3215
by: cwlarsen | last post by:
I want to export a datagrid to Excel. Here is the code: Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition",
1
1348
by: =?Utf-8?B?UGF5cm9sbCBmcnVzdHJhdGVk?= | last post by:
I am on my work computer using Windows XP, I am am using Internet Explorer 7.0 also. I am on a payroll website to do my weekly payroll. I try and view my payroll before processing it so I try and open the payroll preview I open the report which opens in excel and a page opens but I get a blank page. I never had a problem with the report...
0
7201
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7602
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7559
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3279
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1646
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
506
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.