473,804 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Returning Excel Spreadsheet as web page

Hello

I am trying to return the contents of an Excel file. However, I don't want to just redirect the request to the Excel file since it does not reside in a location where that is appropriate. I am trying to write the contents of the file to the response but am having trouble. My code resides in the handler for a link-button's click event

Response.ClearH eaders()
Response.ClearC ontent()
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.AddHea der("Content-Disposition", "attachment;fil ename=" + filename + ".XLS")
Response.WriteF ile(path)
Response.Flush( )
Response.End()

This almost works. When I run it, I get two dialog boxes asking if I want to open or save filename.xls. If I click 'Open' on both, Excel opens up (external from the browser) with the file in it. When I take out the "attachment " designation in the header, I only get 1 dialog box but, if I click 'Open', it ends up displaying the login page of my site in Excel within my browser --- I assume that it is failing some kind of security check or it is being interrpreted as an unauthenticated user at that point

What am I doing wrong? I don't like the two dialog boxes I receive with the code above (and I am sure one of them is resulting in the same behavior of returning the start-page which isn't so good). And, I would prefer that Excel open embedded in the browser instead of in stand-alone mode (although, at this point I would take either behvaior to avoid the second dialog box)

Thanks for any assistance!
Nov 18 '05
10 2219
Hi,

Yes, this problem has been mentioned in the newsgroup. And I've also
consult some experts and confirm t hat this is a known issue of IE. The
problem occurs when the request is send as "post" method, and not occur
when we use get method. Unfortunately the problem won't be fixed currently
and we need to wait the longhorn version. So I'm sorry for any
inconvenience brings to you who has suffer the issue. Thanks for your
understanding.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #11

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

Similar topics

1
47753
by: Jim, N2VX | last post by:
I'd like to create/display an Excel spreadsheet from javascript. We have an HTML page with results of a search and it can be reasonably large. The first attempt was to format the data into an HTML table and send it to an ASP page. The ASP page has: Response.AddHeader ("Content-Disposition", "inline"); Response.ContentType = "application/vnd.ms-excel"); Response.Write(formatted_html_data);
1
1565
by: JV | last post by:
Hi, I'm researching how I can : 1- dynamically generate an Excel spreadsheet by querying a database on an ASP page * I understand how to do this 2- open this spreadsheet by a user (client side) * I understand how to do this
13
1814
by: middletree | last post by:
Curt and McKirahan have been very helpful the past week as I have been introduced to something new to me: generating a spreadsheet from ASP. Now that I have the spreadsheet, I am in need of knowledge about how to control the properties. By properties, I mean font, hyperlink, and color information. I'd like the spreadsheet to have the same data as the HTML page it's getting the data from, but in a different format. I have been searching...
6
6770
by: Daniel | last post by:
Hi all, Can i open and edit the excel sheet on web page after downloading? After editing, i close the web page and the excel file auto upload to the server. Is it possible? I really struggling about the ability. If not, what advice can u provide? thank you in advance. ur help will be appreaciated.
1
2743
by: desi.american | last post by:
I have a dynamically generates ASPX page with tables and data. Depending on user selection, the same page can be viewed as a simple web page (rendered in HTML) or as an excel spreadsheet. If the user chooses to view the page as an excel sheet, I attach the following line of code in C# in the Page_Load method. Response.ContentType = "application/vnd.ms-excel"; All this works fine. But some of cells read nvarchar fields from a database...
0
1062
by: Leonard | last post by:
I am trying to open an excel spreadsheet that is loaded from a datagrid. I have managed to do this. But, my original .aspx page no longer works. I will try to explain. I have an .aspx page - Default.aspx, that gets loaded with an .ascx, depending on the menu item. One of the ascx controls contains a button to load my datagrid and pass it to excel. Excel opens and the spreadsheet is loaded, and that all looks ok, but, the original ascx...
8
9724
by: Mel | last post by:
Can anyone tell me why I am getting this error? It bombs on this line of my VB code: Public appExcel As New Excel.Application It works when I test it on my machine but once I release the page to the web server I get the error when I click on a hyperlink that loads the page. I have the Interop.Excel and Interop.Microsoft.Office.Core references added to my project but I still get this error. What am I missing?
7
28910
Merlin1857
by: Merlin1857 | last post by:
Its great producing data for users to look at in your web pages and generally that is sufficient for their needs but sometimes you may want to supply your user with the data in a form they can actually do something more with. This code shows you how to display data from your database and then how to give that data to the user in the form of a useable Excel spreadsheet which they can then take away and play with themselves. The way I have shown...
3
4472
by: S_K | last post by:
Hi, I have a problem when I try to save a .CSV file from an ASP.NET web page and the client has Excel open already. The symptoms are: 1) The web page is currently displaying the Excel spreadsheet with the accurate data. 2) The .CSV file is saved from the server to the local hard drive of the client. 3) An Excel spreadsheet is already running on the client (version 2002
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9584
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10583
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9160
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4301
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

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.