473,511 Members | 16,260 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending xls file from Server to Client via asp.net

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



Nov 19 '05 #1
1 2142
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
"Lars Netzel" <ui****@adf.se> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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



Nov 19 '05 #2

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

Similar topics

15
4282
by: Sven Templin | last post by:
Hello all, our configuration is as following described: - OS: Windows 2000 - Apache server 1.3 - Php 3.8 - MS outlook client 2000 _and_ no SMTP server available in the whole intranet.
20
2438
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to...
5
1745
by: vanisathish | last post by:
Hi All, I need to constantly update some values to the User Interface. In order to do the updation efficiently, i am planning to run some script in the server side that constantly keeps sending...
4
8189
by: yaron | last post by:
Hi, I have a problem when sending data over TCP socket from c# client to java server. the connection established ok, but i can't send data from c# client to java server. it's work ok with...
4
1443
by: Drygast | last post by:
I have a form that updates an accessdatabase, when I close the form I have put a question wheter to send the database to the intenet or not. Is it possible to automatically check if the database...
1
1807
by: Henk | last post by:
Hi, I have a problem with sending a file. I have a client application that connects to a server and sends the string "data". Then it sends a file. If the server receives "data", the method...
1
8154
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
0
1310
by: Lee | last post by:
Hi, I am trying to send and receive a file (it is actually an xml file, however any file may possibly be sent) using;- sending ..... public void send() {
4
1772
by: AtulSureka | last post by:
Hi, I have file of relatively larger size (4-5 Mbs) on client machine. I want to send this file to Server. For this I am using web services. Following is my perception, Please correct me if I...
0
7242
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,...
1
7075
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...
0
7508
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5063
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...
0
4737
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...
0
3222
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...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
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 ...
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.