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.EventArgs) Handles MyBase.Load
Dim path As String
Dim fs As New FileStream(path, FileMode.Open)
Dim byteRead As Integer
path = Server.MapPath(Request("fileToDownload"))
Response.ClearHeaders()
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" &
Request("fileToDownload").ToString
Response.ContentType = "application/XYZ"
byteRead = fs.ReadByte()
While byteRead <> -1
Response.Write(byteRead)
byteRead = fs.ReadByte()
End While
fs.Close()
End Sub 4 21776
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.AddHeader("Content-Disposition", "attachment; filename=" &
Ali,
You are missing the ContentType setting.
Response.ContentType = "application/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**************@TK2MSFTNGP11.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.AddHeader("Content-Disposition", "attachment; filename=" &
Ali, You are missing the ContentType setting. Response.ContentType = "application/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.Writefile method.
Something like this should work:
Response.Clear();
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition","attachment;filename=myfile.xls");
Response.WriteFile("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********@hotmail.com> wrote in message
news:Oq**************@TK2MSFTNGP09.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**************@TK2MSFTNGP11.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.AddHeader("Content-Disposition", "attachment; filename=" &
Ali, You are missing the ContentType setting. Response.ContentType = "application/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.net> wrote in message
news:#7**************@TK2MSFTNGP12.phx.gbl... To go along with Carl's answer, you can use the Response.Writefile method. Something like this should work:
Response.Clear(); Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition","attachment;filename=myfile.xls"); Response.WriteFile("myfile.xls");
Here's more info: http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwebhttpresponseclasswritefiletopic.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********@hotmail.com> wrote in message news:Oq**************@TK2MSFTNGP09.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**************@TK2MSFTNGP11.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.AddHeader("Content-Disposition", "attachment; filename=" & >
Ali, You are missing the ContentType setting. Response.ContentType = "application/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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
by: appu123 |
last post by:
does perl allow the download of excel files i.e. in xls or csv format ???
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |