Sending xls file from Server to Client via asp.net

L

Lars Netzel

I have an XLS file that I try to send to the webclient via ASP.NET. When
sending I use this code...
Response.ClearContent()

Response.ClearHeaders()

Response.ContentType = "application/vnd.ms-excel"

Response.AddHeader("Content-Disposition", "inline; filename=" &
ClientFilename & ".xls")

Response.WriteFile(Filename)

Response.Flush()

The Problem:

When clicking the link that is running this code the "_blank" window that is
suppoed to show the excel file, closes imediately... it's like.. I click..
a new window opens and closes right away.. no error messages

I do the same for a PDF file with the only exception for the contenttype and
extention of the file name. and that works fine.

What's the problem you think? why does a PDF work and not the Xls file?

best regards

/Lars
 
S

S. Justin Gengo

Lars,

I'm not certain if this will help in your situation or not. I was just
looking over some code of mine for outputting a datagrid as an excel file so
it's a little bit different than your code, but I do two things before
sending the stream to the client that you're not doing:

1.. '---Clear the characterset
2.. Response.Charset = ""
3..
4.. '---Viewstate must be turned off.
5.. Me.EnableViewState = False
Maybe adding this will work.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top