I need a functionality where my clients download Excel files and after they
do, I do some processing. Downloading is easily achieved using a anchor or
hyperlink tag, but that does not give me the full functionality I am after.
So, I came up with a way to download the files using a stream but after I
download the file and try to open it in Excel I get garbage.
This is the code I use for the download function. Please help if you have
any ideas or suggestions. Thanks in advance.
Ali
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim path As String
Dim fs As New FileStream(path , FileMode.Open)
Dim byteRead As Integer
path = Server.MapPath( Request("fileTo Download"))
Response.ClearH eaders()
Response.Clear( )
Response.AddHea der("Content-Disposition", "attachment ; filename=" &
Request("fileTo Download").ToSt ring
Response.Conten tType = "applicatio n/XYZ"
byteRead = fs.ReadByte()
While byteRead <> -1
Response.Write( byteRead)
byteRead = fs.ReadByte()
End While
fs.Close()
End Sub 4 21843
Ali wrote: I need a functionality where my clients download Excel files and after they do, I do some processing. Downloading is easily achieved using a anchor or hyperlink tag, but that does not give me the full functionality I am after. So, I came up with a way to download the files using a stream but after I download the file and try to open it in Excel I get garbage.
Response.AddHea der("Content-Disposition", "attachment ; filename=" &
Ali,
You are missing the ContentType setting.
Response.Conten tType = "applicatio n/vnd.ms-excel" http://support.microsoft.com/default...Product=aspnet
Also, please don't cross-post to so many newsgroups.
--
Thanks,
Carl Prothman
Microsoft ASP.NET MVP
Thanks Carl and I am sorry for cross posting. I just did not know any
better.
Your response assumes that I need to create an excel file using ASP.NET.
The problem is that I already have the Excel file on the server. All I want
to do is download it. But not using the anchor nor the hyperlink tags.
Ali http://support.microsoft.com/default...&Product=aspne
t
"Carl Prothman [MVP]" <ca****@spamcop .net> wrote in message
news:#9******** ******@TK2MSFTN GP11.phx.gbl... Ali wrote: I need a functionality where my clients download Excel files and after they do, I do some processing. Downloading is easily achieved using a anchor or hyperlink tag, but that does not give me the full functionality I am after. So, I came up with a way to download the files using a stream but after I download the file and try to open it in Excel I get garbage.
Response.AddHea der("Content-Disposition", "attachment ; filename=" &
Ali, You are missing the ContentType setting. Response.Conten tType = "applicatio n/vnd.ms-excel" http://support.microsoft.com/default...&Product=aspne
t Also, please don't cross-post to so many newsgroups.
--
Thanks, Carl Prothman Microsoft ASP.NET MVP
To go along with Carl's answer, you can use the Response.Writef ile method.
Something like this should work:
Response.Clear( );
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.AddHea der("Content-Disposition","a ttachment;filen ame=myfile.xls" );
Response.WriteF ile("myfile.xls ");
Here's more info: http://msdn.microsoft.com/library/de...efiletopic.asp http://www.aspnetpro.com/NewsletterA...200309so_l.asp
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Ali" <el********@hot mail.com> wrote in message
news:Oq******** ******@TK2MSFTN GP09.phx.gbl... Thanks Carl and I am sorry for cross posting. I just did not know any better.
Your response assumes that I need to create an excel file using ASP.NET. The problem is that I already have the Excel file on the server. All I
want to do is download it. But not using the anchor nor the hyperlink tags.
Ali http://support.microsoft.com/default...&Product=aspne t
"Carl Prothman [MVP]" <ca****@spamcop .net> wrote in message news:#9******** ******@TK2MSFTN GP11.phx.gbl... Ali wrote: I need a functionality where my clients download Excel files and after they do, I do some processing. Downloading is easily achieved using a anchor or hyperlink tag, but that does not give me the full functionality I am after. So, I came up with a way to download the files using a stream but after I download the file and try to open it in Excel I get garbage.
Response.AddHea der("Content-Disposition", "attachment ; filename=" &
Ali, You are missing the ContentType setting. Response.Conten tType = "applicatio n/vnd.ms-excel" http://support.microsoft.com/default...&Product=aspne t Also, please don't cross-post to so many newsgroups.
--
Thanks, Carl Prothman Microsoft ASP.NET MVP
Exactly what I needed Steve. Thanks Dude.
Ali
"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:#7******** ******@TK2MSFTN GP12.phx.gbl... To go along with Carl's answer, you can use the Response.Writef ile method. Something like this should work:
Response.Clear( ); Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.AddHea der("Content-Disposition","a ttachment;filen ame=myfile.xls" ); Response.WriteF ile("myfile.xls ");
Here's more info: http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwebh ttpresponseclas swritefiletopic .asp
http://www.aspnetpro.com/NewsletterA..._l/asp200309so
_l.asp -- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net Hire top-notch developers at http://www.able-consulting.com "Ali" <el********@hot mail.com> wrote in message news:Oq******** ******@TK2MSFTN GP09.phx.gbl... Thanks Carl and I am sorry for cross posting. I just did not know any better.
Your response assumes that I need to create an excel file using ASP.NET. The problem is that I already have the Excel file on the server. All I want to do is download it. But not using the anchor nor the hyperlink tags.
Ali http://support.microsoft.com/default...&Product=aspne t
"Carl Prothman [MVP]" <ca****@spamcop .net> wrote in message news:#9******** ******@TK2MSFTN GP11.phx.gbl... Ali wrote: > I need a functionality where my clients download Excel files and > after they do, I do some processing. Downloading is easily achieved > using a anchor or hyperlink tag, but that does not give me the full > functionality I am after. So, I came up with a way to download the > files using a stream but after I download the file and try to open
it > in Excel I get garbage. > > Response.AddHea der("Content-Disposition", "attachment ; filename=" & >
Ali, You are missing the ContentType setting. Response.Conten tType = "applicatio n/vnd.ms-excel" http://support.microsoft.com/default...&Product=aspne t Also, please don't cross-post to so many newsgroups.
--
Thanks, Carl Prothman Microsoft ASP.NET MVP
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dux |
last post by:
I have used some example code to create a database in MySQL and using
php I can add binary files to the database. I was under the impression
that I would be able to download the files with the source code
provided, but am having trouble doing that.
<?php
if ($id_files) {
include "./include/open_db.inc";
$sql = "SELECT bin_data, filetype, filename, filesize FROM tbl_Files
WHERE id_files=$id_files";
|
by: Ali |
last post by:
I need a functionality where my clients download Excel files and after they
do, I do some processing. Downloading is easily achieved using a anchor or
hyperlink tag, but that does not give me the full functionality I am after.
So, I came up with a way to download the files using a stream but after I
download the file and try to open it in Excel I get garbage.
This is the code I use for the download function. Please help if you have
any...
|
by: moondaddy |
last post by:
I have a asp.net app where a user will need to download multiple files at
once.
Below is some sample code I'm using to download a single file which works
perfectly, however, rather than a single file, I need to download all the
image files for a single order being processed by the user. Is it possible
to download a batch or group of files?
Thanks.
|
by: Boris Condarco |
last post by:
Hi gurus,
I'm using excel 2000 to show data that comes from datagrid. The problem is
that for any reason the asp.net application maintains the excel open, even
though, i do close it. Besides, does anyone know any third party compononet
to write excel files without having it installed?
My code looks like:
Public Function toExcel(ByVal fileName As String, ByVal dv As DataView)
|
by: Barbara Alderton |
last post by:
I’m relatively new to .NET. I would like to write a VB.NET app (I read that using C# isn't as elegant when dealing with Office products) that reads in Excel files (forms) of both 2000 and 2003 versions, off a file system. I want to access the different cells, some fixed and some variable, and retrieve this data and input it into a SQL 2000 database. Can I do this using the Excel Object model within the VB.NET code? What are the...
| |
by: Loane Sharp |
last post by:
Hi there
I'm downloading data from a remote server to my local disk using
Stream.Read() and Stream.Write() (as previously suggested by Ken Tucker in
this group). By and large the download and local write operations occur
successfully, but frequently the data transfer is "intermittent", ie.
sometimes the connection to the server becomes idle and no data transfer
occurs over the wire. The code eventually resumes execution as if all the...
|
by: Wensui Liu |
last post by:
Dear all,
right now, I have 20 something excel reports that need to be converted
to pdf and I have pdf write installed on my PC.
Is there a way that I can do so in python?
|
by: =?Utf-8?B?SnVhbg==?= |
last post by:
Hi!
I want to use ASP to download big files using ADODB.STREAM. It works very
fine with files smaller than 80 MB.
On the Webserver I can see that memory allocation and the process w3wp is
running. After some time (more or less 2 minutes) I get a response timeout.
Here is the code:
|
by: appu123 |
last post by:
does perl allow the download of excel files i.e. in xls or csv format ???
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |