Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Opening a file in excel via asp.net

Reply
Thread Tools

Opening a file in excel via asp.net

 
 
Vishal
Guest
Posts: n/a
 
      01-12-2005
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.
 
Reply With Quote
 
 
 
 
Philip Q [MVP]
Guest
Posts: n/a
 
      01-12-2005
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" <> wrote in message
news:032801c4f862$2b55c020$...
> 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.



 
Reply With Quote
 
 
 
 
Vishal
Guest
Posts: n/a
 
      01-12-2005
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" <> wrote in

message
>news:032801c4f862$2b55c020$...
>> 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.

>
>
>.
>

 
Reply With Quote
 
Philip Q [MVP]
Guest
Posts: n/a
 
      01-12-2005
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" <> wrote in message
news:23c401c4f8af$36e32e80$...
>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" <> wrote in

> message
>>news:032801c4f862$2b55c020$...
>>> 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.

>>
>>
>>.
>>



 
Reply With Quote
 
Dave Fancher
Guest
Posts: n/a
 
      01-13-2005
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]" <> wrote in message
news:%23eh0ZFL%...
> 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" <> wrote in message
> news:23c401c4f8af$36e32e80$...
>>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" <> wrote in

>> message
>>>news:032801c4f862$2b55c020$.. .
>>>> 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.
>>>
>>>
>>>.
>>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with opening Excel after opening Excel inside Microsoft Internet Controls fniles ASP General 0 04-26-2009 09:39 PM
Problem with Excel reports ::::Excel 2003 Migration To Excel 2007 =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?= ASP .Net 15 10-24-2007 01:34 PM
adding an excel worksheet to a generetad excel file via perl FlorianKraft@gmx.de Perl Misc 1 04-17-2007 12:53 PM
Word file not opening from Adm -My recent docs but opening from file menu of Word Thaqalain Computer Support 0 06-30-2005 02:20 AM
OLE & Excel - Opening causes Excel.exe to hang around TimmyD Perl Misc 0 04-21-2005 07:20 PM



Advertisments