473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Error downloading excel file

Greetings,

I have the following code that attempts to download an excel file:

System.Web.HttpContext.Current.Response.ContentTyp e =
"application/vnd.ms-excel";

System.Web.HttpContext.Current.Response.AddHeader( "Content-Disposition",
"attachment; filename=\"x.xls\"");

System.Web.HttpContext.Current.Response.Write( "abc" );
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.Close();

But I get the following error when I executed the last statement:

"Internet Explorer was not able to open this internet site..."

I have disabled "Content Expiration" in IIS HTTP Headers and ensured
"no-cache" is not added to the Response Header.

Has anyone seen this and knows what is causing it?

Help is much appreciated,
kr

*** Sent via Developersdex http://www.developersdex.com ***
Jan 11 '06 #1
4 3054
Try Response.End() instead of Response.Close()

--
Andrew Robinson
http://blog.binaryocean.com
"Kevin R." <ka****@riverone.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Greetings,

I have the following code that attempts to download an excel file:

System.Web.HttpContext.Current.Response.ContentTyp e =
"application/vnd.ms-excel";

System.Web.HttpContext.Current.Response.AddHeader( "Content-Disposition",
"attachment; filename=\"x.xls\"");

System.Web.HttpContext.Current.Response.Write( "abc" );
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.Close();

But I get the following error when I executed the last statement:

"Internet Explorer was not able to open this internet site..."

I have disabled "Content Expiration" in IIS HTTP Headers and ensured
"no-cache" is not added to the Response Header.

Has anyone seen this and knows what is causing it?

Help is much appreciated,
kr

*** Sent via Developersdex http://www.developersdex.com ***

Jan 11 '06 #2
I got the same error. I tried to download a .csv file and hit the same
problem, so this is not Excel related. It must be either something in my
IE 6.0 or a .NET configuration issue.

Any other ideas?

thx,
kr
*** Sent via Developersdex http://www.developersdex.com ***
Jan 16 '06 #3
Try Response.Clear() before you start adding things to the Response.

http://www.csvreader.com/csv_samples.html
The section marked "Download DataTable to Web Browser as CSV File".

Jan 17 '06 #4

Shriop,

Thanks for your suggestion and the reference URL. It took me one step
closer to the solution. Now, when I click the "Save" button of the "File
Download" dialog it saves the content as a .xls file with no problem.

But, if I choose to open the content by clicking on the "Open" button
and if Excel app is not already open in my desktop, it opens Excel
application with the following error:

'C:\Document and Settings\username\LocalSettings\Temporary Internet
Files\Content.IE5\KV5ZIYV1\myfilename.xls could not be found...'

If however, Excel is already open prior to clicking the "Open" button it
shows the content in Excel with no problem. Is this normal behavior? How
can I make it to launch Excel first and show the content?

your help is much appreciated.

Regards,
kr

*** Sent via Developersdex http://www.developersdex.com ***
Jan 17 '06 #5

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

Similar topics

3
by: Jocelyn Duhaylungsod | last post by:
I have been getting the following server errors sporadically while downloading excel, csv or xml file. Internet Explorer cannot download <file name> from <IP address> "The server returned an...
0
by: ed | last post by:
Hello All. I have seen many posts slightly similar to this question with no answer. Maybe you have some FAQs or something, sorry if I looks repetitive. Here is my Problem: In my...
2
by: Radha Raman | last post by:
hi I am facing problem in downloading excel sheet with macros. So i decide to create a EXE for that. But how to create that EXE for downloading excel file, i don't know. Plz help me
1
by: Muddasir | last post by:
Hello everyone. I am facing problem in downloading .xls file. I generate report and save data in excel sheet on server. and once user click the 'save data in excel format', an excel sheet is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.