By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,971 Members | 907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,971 IT Pros & Developers. It's quick & easy.

Opening a file in excel via asp.net

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.