473,381 Members | 1,531 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,381 software developers and data experts.

Opening a file in excel via asp.net

Hello,

I have a dataset with some content. I can convert this
dataset in a csv format which is then stored in a
stringwriter. Now I want this be open via excel, so I set
the contenttype "application/vnd.ms-excel". To access this
page the user requires to login, once the user is logged
in he can access this file. Now when this file is opened
in excel it shows me the login screen instead of the data.
The user is already logged in, so why does it show me the
login screen in excel?

Any help is appreciated.
Nov 19 '05 #1
4 2205
What might be happening (I'm not too sure how Excel interacts with the
browser) is that instead of the browser sending the data to Excel, Excel is
initiating a direct request to the webserver to retrieve the data.
The problem is that the website knows that you are logged in when using the
browser (with Session Cookies, or however you are doing it), but Excel does
not have access to those cookies and so the website does not know that the
user is logged in.

Assuming this is the case, the easiest way around it would be to make users
download the Excel file before opening it.

--
Philip Q
Microsoft MVP [ASP.NET]

"Vishal" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
Hello,

I have a dataset with some content. I can convert this
dataset in a csv format which is then stored in a
stringwriter. Now I want this be open via excel, so I set
the contenttype "application/vnd.ms-excel". To access this
page the user requires to login, once the user is logged
in he can access this file. Now when this file is opened
in excel it shows me the login screen instead of the data.
The user is already logged in, so why does it show me the
login screen in excel?

Any help is appreciated.

Nov 19 '05 #2
I think you are right. But how do I let the user download
the csv file? I dont want to create it and store it on the
web server. I would like to create it on the fly and send
a temp file or something like that.

Thanks for any help.

-----Original Message-----
What might be happening (I'm not too sure how Excel interacts with thebrowser) is that instead of the browser sending the data to Excel, Excel isinitiating a direct request to the webserver to retrieve the data.The problem is that the website knows that you are logged in when using thebrowser (with Session Cookies, or however you are doing it), but Excel doesnot have access to those cookies and so the website does not know that theuser is logged in.

Assuming this is the case, the easiest way around it would be to make usersdownload the Excel file before opening it.

--
Philip Q
Microsoft MVP [ASP.NET]

"Vishal" <an*******@discussions.microsoft.com> wrote in messagenews:03****************************@phx.gbl...
Hello,

I have a dataset with some content. I can convert this dataset in a csv format which is then stored in a
stringwriter. Now I want this be open via excel, so I set the contenttype "application/vnd.ms-excel". To access this page the user requires to login, once the user is logged
in he can access this file. Now when this file is opened
in excel it shows me the login screen instead of the data. The user is already logged in, so why does it show me the login screen in excel?

Any help is appreciated.

.

Nov 19 '05 #3
If users are not prompted to download, they will have to right-click on the
link and choose Save Target As... (or equivalent) - this is an issue with
their browser.

--
Philip Q
Microsoft MVP [ASP.NET]

"Vishal" <an*******@discussions.microsoft.com> wrote in message
news:23****************************@phx.gbl...
I think you are right. But how do I let the user download
the csv file? I dont want to create it and store it on the
web server. I would like to create it on the fly and send
a temp file or something like that.

Thanks for any help.

-----Original Message-----
What might be happening (I'm not too sure how Excel

interacts with the
browser) is that instead of the browser sending the data

to Excel, Excel is
initiating a direct request to the webserver to retrieve

the data.
The problem is that the website knows that you are logged

in when using the
browser (with Session Cookies, or however you are doing

it), but Excel does
not have access to those cookies and so the website does

not know that the
user is logged in.

Assuming this is the case, the easiest way around it

would be to make users
download the Excel file before opening it.

--
Philip Q
Microsoft MVP [ASP.NET]

"Vishal" <an*******@discussions.microsoft.com> wrote in

message
news:03****************************@phx.gbl...
Hello,

I have a dataset with some content. I can convert this dataset in a csv format which is then stored in a
stringwriter. Now I want this be open via excel, so I set the contenttype "application/vnd.ms-excel". To access this page the user requires to login, once the user is logged
in he can access this file. Now when this file is opened
in excel it shows me the login screen instead of the data. The user is already logged in, so why does it show me the login screen in excel?

Any help is appreciated.

.

Nov 19 '05 #4
Depending on how you have your page set up, you may be able to use the
"Content-Disposition" header (example below). There are plenty of full
examples available via google. Adding the line below to your aspx (or code
behind, which ever method you're using) will cause the browser to
automatically pop up the open/save dialog box.

// sample only, read up on this to ensure you can use it
Response.AddHeader("Content-Disposition", "attachment; filename=List.csv");

--
Dave Fancher
http://davefancher.blogspot.com
"Philip Q [MVP]" <wi******@NOSPAMmvps.org> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
If users are not prompted to download, they will have to right-click on
the link and choose Save Target As... (or equivalent) - this is an issue
with their browser.

--
Philip Q
Microsoft MVP [ASP.NET]

"Vishal" <an*******@discussions.microsoft.com> wrote in message
news:23****************************@phx.gbl...
I think you are right. But how do I let the user download
the csv file? I dont want to create it and store it on the
web server. I would like to create it on the fly and send
a temp file or something like that.

Thanks for any help.

-----Original Message-----
What might be happening (I'm not too sure how Excel

interacts with the
browser) is that instead of the browser sending the data

to Excel, Excel is
initiating a direct request to the webserver to retrieve

the data.
The problem is that the website knows that you are logged

in when using the
browser (with Session Cookies, or however you are doing

it), but Excel does
not have access to those cookies and so the website does

not know that the
user is logged in.

Assuming this is the case, the easiest way around it

would be to make users
download the Excel file before opening it.

--
Philip Q
Microsoft MVP [ASP.NET]

"Vishal" <an*******@discussions.microsoft.com> wrote in

message
news:03****************************@phx.gbl.. .
Hello,

I have a dataset with some content. I can convert

this
dataset in a csv format which is then stored in a
stringwriter. Now I want this be open via excel, so I

set
the contenttype "application/vnd.ms-excel". To access

this
page the user requires to login, once the user is logged
in he can access this file. Now when this file is opened
in excel it shows me the login screen instead of the

data.
The user is already logged in, so why does it show me

the
login screen in excel?

Any help is appreciated.
.


Nov 19 '05 #5

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

Similar topics

1
by: Bob Murdoch | last post by:
I've got an intranet application that presents a list of files in sort of a 'central repository' web page. Each file is an href in the form <a href=file://server/share/path/filename.ext>. When...
1
by: ST | last post by:
Hi, I'm having problems opening up excel thru my code. It will write and saveas an excel file, but the application won't open on the user's computer, excel seems to be hidden, because it shows up...
0
by: Garth | last post by:
Hi, I'm opening and closing an excel using C#. Once the file has been opened and closed I then double click on the file with Windows Explorer and excel opens and then just hangs. Can anyone help?...
2
by: Jacob.Bruxer | last post by:
Hi everyone, I'm having trouble opening space delimited textfiles in Excel from Visual Basic.net. I'm able to control, open and modify Excel files from Visual Basic, so my Excel reference seems...
2
by: Mad Scientist Jr | last post by:
>From an asp.net web page I want the user to open the results of a SQL query in Excel, as automatically as possible (ie not having to loop through columns, rows, in code). For this,...
1
by: mohanprasadgutta | last post by:
Hi, I need help to open a password protected excel file in perl using Win32:OLE. when I tried to open file in normal way at the time of program execution it is prompting me to enter password. I am...
16
by: Phil Stanton | last post by:
I have a form with a button which is supposed to open an Excel file (With lots of Macros /VBA) in it. The Excel file gets it's data from the Access program Here is the code Private Sub...
0
by: shyshack | last post by:
Hi, I am quite new in C#. I am writing an application in which I have to open Excel file to import data from it. When opening small files everything works ok - the problem appears when I try to...
1
navanova
by: navanova | last post by:
Greetings, I have a problem of opening ms word and excel files on my computer. The files are there for a long time. I use to open and modify them. Suddenly, when i try to open the word files, a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.