473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

auto download csv file

How can I force a download of a csv file by user clicking on hyperlink.
Don
Jul 19 '05 #1
6 18600
try :

<a href="myCSVFile.csv">click here</a>

If it opens in the browser then the user needs to amend their settings.

see http://www.greggriffiths.org/webdev/both/excel/ for some other
approaches.

Don Grover wrote:
How can I force a download of a csv file by user clicking on hyperlink.
Don


Jul 19 '05 #2
Thanks Greg.
Had a look but what I am after, I have a complex qry that financial users
select data from a web page by submitting a form.
I am calling an asp page that gets the data format as they require and I
have it a STRING in csv format.
The above is working correctly.

What I want to do is automatically bring up a save as box to prompt them to
save it, I really dont want to save as file first unless I have too.

Anyone have any ideas.
Don

"Greg Griffiths" <gr***@surfaid.org> wrote in message
news:3F***************@surfaid.org...
try :

<a href="myCSVFile.csv">click here</a>

If it opens in the browser then the user needs to amend their settings.

see http://www.greggriffiths.org/webdev/both/excel/ for some other
approaches.

Don Grover wrote:
How can I force a download of a csv file by user clicking on hyperlink.
Don

Jul 19 '05 #3
Look at ADODB.Stream
http://support.microsoft.com/default...NoWebContent=1

You can load the object with the CSV and as long as the HTTP headers are set
correctly thenthe binary output (as Response.Write) will prompt the Save AS
dialog.

<%
'Set the content type to the specific type that you are sending.
Response.ContentType = "text/csv"

Const adTypeText = 2

'Create Stream object
Dim pobjStream
Set pobjStream = Server.CreateObject("ADODB.Stream")

'Specify stream type - we want To save text/string data.
pobjStream.Type = adTypeText

'Open the stream And write binary data To the object
pobjStream.Open
pobjStream.WriteText [YourGeneratedCSVText]

Response.BinaryWrite objStream.Read

pobjStream.Close
Set pobjStream = Nothing
%>
**** That might be Response.Write as opposed to BinaryWrite - not sure at
the moment.

Chris.

"Don Grover" <sp******@assoft.com.au> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Thanks Greg.
Had a look but what I am after, I have a complex qry that financial users
select data from a web page by submitting a form.
I am calling an asp page that gets the data format as they require and I
have it a STRING in csv format.
The above is working correctly.

What I want to do is automatically bring up a save as box to prompt them to
save it, I really dont want to save as file first unless I have too.

Anyone have any ideas.
Don

"Greg Griffiths" <gr***@surfaid.org> wrote in message
news:3F***************@surfaid.org...
try :

<a href="myCSVFile.csv">click here</a>

If it opens in the browser then the user needs to amend their settings.

see http://www.greggriffiths.org/webdev/both/excel/ for some other
approaches.

Don Grover wrote:
How can I force a download of a csv file by user clicking on hyperlink.
Don

Jul 19 '05 #4
Thanks Chris
I can now get it to show a saved as box but it keeps putting in the actual
asp page as the file saveas file name.
How can I preload a file name.
'****************************
Heres my Code

'Set the content type to the specific type that you are sending.
Response.ContentType = "text/csv"

Const adTypeBinary = 1
Dim strFilePath

strFilePath = "c:\cokeshopScripts\exportdata.csv" 'This is the path to the
file on disk.

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath

Response.Binarywrite objStream.Read

objStream.Close
Set objStream = Nothing

'******************************************

"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Look at ADODB.Stream
http://support.microsoft.com/default...NoWebContent=1
You can load the object with the CSV and as long as the HTTP headers are set correctly thenthe binary output (as Response.Write) will prompt the Save AS dialog.

<%
'Set the content type to the specific type that you are sending.
Response.ContentType = "text/csv"

Const adTypeText = 2

'Create Stream object
Dim pobjStream
Set pobjStream = Server.CreateObject("ADODB.Stream")

'Specify stream type - we want To save text/string data.
pobjStream.Type = adTypeText

'Open the stream And write binary data To the object
pobjStream.Open
pobjStream.WriteText [YourGeneratedCSVText]

Response.BinaryWrite objStream.Read

pobjStream.Close
Set pobjStream = Nothing
%>
**** That might be Response.Write as opposed to BinaryWrite - not sure at
the moment.

Chris.

"Don Grover" <sp******@assoft.com.au> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Thanks Greg.
Had a look but what I am after, I have a complex qry that financial users
select data from a web page by submitting a form.
I am calling an asp page that gets the data format as they require and I
have it a STRING in csv format.
The above is working correctly.

What I want to do is automatically bring up a save as box to prompt them to save it, I really dont want to save as file first unless I have too.

Anyone have any ideas.
Don

"Greg Griffiths" <gr***@surfaid.org> wrote in message
news:3F***************@surfaid.org...
try :

<a href="myCSVFile.csv">click here</a>

If it opens in the browser then the user needs to amend their settings.

see http://www.greggriffiths.org/webdev/both/excel/ for some other
approaches.

Don Grover wrote:
How can I force a download of a csv file by user clicking on hyperlink. Don


Jul 19 '05 #5
Response.addHeader("content-disposition",
"attachment;filename=somefile.csv")

Chris.

"Don Grover" <sp******@assoft.com.au> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Thanks Chris
I can now get it to show a saved as box but it keeps putting in the actual
asp page as the file saveas file name.
How can I preload a file name.
'****************************
Heres my Code

'Set the content type to the specific type that you are sending.
Response.ContentType = "text/csv"

Const adTypeBinary = 1
Dim strFilePath

strFilePath = "c:\cokeshopScripts\exportdata.csv" 'This is the path to the
file on disk.

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath

Response.Binarywrite objStream.Read

objStream.Close
Set objStream = Nothing

'******************************************

"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Look at ADODB.Stream
http://support.microsoft.com/default...NoWebContent=1
You can load the object with the CSV and as long as the HTTP headers are set correctly thenthe binary output (as Response.Write) will prompt the Save AS dialog.

<%
'Set the content type to the specific type that you are sending.
Response.ContentType = "text/csv"

Const adTypeText = 2

'Create Stream object
Dim pobjStream
Set pobjStream = Server.CreateObject("ADODB.Stream")

'Specify stream type - we want To save text/string data.
pobjStream.Type = adTypeText

'Open the stream And write binary data To the object
pobjStream.Open
pobjStream.WriteText [YourGeneratedCSVText]

Response.BinaryWrite objStream.Read

pobjStream.Close
Set pobjStream = Nothing
%>
**** That might be Response.Write as opposed to BinaryWrite - not sure at
the moment.

Chris.

"Don Grover" <sp******@assoft.com.au> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Thanks Greg.
Had a look but what I am after, I have a complex qry that financial users
select data from a web page by submitting a form.
I am calling an asp page that gets the data format as they require and I
have it a STRING in csv format.
The above is working correctly.

What I want to do is automatically bring up a save as box to prompt them to save it, I really dont want to save as file first unless I have too.

Anyone have any ideas.
Don

"Greg Griffiths" <gr***@surfaid.org> wrote in message
news:3F***************@surfaid.org...
try :

<a href="myCSVFile.csv">click here</a>

If it opens in the browser then the user needs to amend their settings.

see http://www.greggriffiths.org/webdev/both/excel/ for some other
approaches.

Don Grover wrote:
How can I force a download of a csv file by user clicking on hyperlink. Don



Jul 19 '05 #6
Thanks chris, works like a dream.

"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> wrote in message
news:eU**************@TK2MSFTNGP12.phx.gbl...
Response.addHeader("content-disposition",
"attachment;filename=somefile.csv")

Chris.

"Don Grover" <sp******@assoft.com.au> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Thanks Chris
I can now get it to show a saved as box but it keeps putting in the actual
asp page as the file saveas file name.
How can I preload a file name.
'****************************
Heres my Code

'Set the content type to the specific type that you are sending.
Response.ContentType = "text/csv"

Const adTypeBinary = 1
Dim strFilePath

strFilePath = "c:\cokeshopScripts\exportdata.csv" 'This is the path to the
file on disk.

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath

Response.Binarywrite objStream.Read

objStream.Close
Set objStream = Nothing

'******************************************

"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Look at ADODB.Stream

http://support.microsoft.com/default...NoWebContent=1

You can load the object with the CSV and as long as the HTTP headers are

set
correctly thenthe binary output (as Response.Write) will prompt the Save

AS
dialog.

<%
'Set the content type to the specific type that you are sending.
Response.ContentType = "text/csv"

Const adTypeText = 2

'Create Stream object
Dim pobjStream
Set pobjStream = Server.CreateObject("ADODB.Stream")

'Specify stream type - we want To save text/string data.
pobjStream.Type = adTypeText

'Open the stream And write binary data To the object
pobjStream.Open
pobjStream.WriteText [YourGeneratedCSVText]

Response.BinaryWrite objStream.Read

pobjStream.Close
Set pobjStream = Nothing
%>
**** That might be Response.Write as opposed to BinaryWrite - not sure at
the moment.

Chris.

"Don Grover" <sp******@assoft.com.au> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Thanks Greg.
Had a look but what I am after, I have a complex qry that financial users select data from a web page by submitting a form.
I am calling an asp page that gets the data format as they require and I
have it a STRING in csv format.
The above is working correctly.

What I want to do is automatically bring up a save as box to prompt them

to
save it, I really dont want to save as file first unless I have too.

Anyone have any ideas.
Don

"Greg Griffiths" <gr***@surfaid.org> wrote in message
news:3F***************@surfaid.org...
try :

<a href="myCSVFile.csv">click here</a>

If it opens in the browser then the user needs to amend their settings.
see http://www.greggriffiths.org/webdev/both/excel/ for some other
approaches.

Don Grover wrote:

> How can I force a download of a csv file by user clicking on

hyperlink. > Don



Jul 19 '05 #7

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

Similar topics

5
by: Barry | last post by:
Hello, I've recently noticed that someone can simply type in the URL to my javaScript, from my HTML source code, to the explorer location bar and an auto-save dialog pops up to let them save it...
11
by: UJ | last post by:
Has anybody had any experience writing an auto update program that will check the internet to see if there is a newer version of the code out there and download it? It doesn't seem that...
1
by: Alex | last post by:
Hi, Everyday, I download data from a webpage and manually input data into my MS Access database. I am thinking of automate the routine by a VB script. The webpage I am visiting will return a...
1
by: Poewood | last post by:
My previous msg was poorly worded. What kind of class should I use to upload and download a file from the internet? I want to create a fuction for a pocket pc that will enable me to...
5
by: Brakeshoe | last post by:
I would like to find out how to turn on the Auto Complete variable names feature while editing source code in Visual Studio. It seems to appear on intermittantly, and when it does the variable...
17
by: Dino M. Buljubasic | last post by:
I am building an applicatin that will be able to automatically update itself from an FTP server. I'd like to be able to determine which version of application is newer, the one currently running...
1
by: Carlo | last post by:
I am trying to seek the following functionality: A user clicks on a download buton I can automatically download a file, but since in the end i must end the response, its either the download or...
8
by: deciacco | last post by:
I created a deployment project for my .net 2 application in vs 2005. In the properties of the deployment project, under prerequisites i have "Create setup program to install prerequisite components"...
3
by: cypherkro | last post by:
Hi I have a requirement to automatically download a file using a WebBrowser control without having the "Download File" pop up windows display. I cannot use Webclient!! I am using VS2005, .net2...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
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
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...
0
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...

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.