a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Hosting from $3.99 per month!

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions. dd

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Output Form Results to CSV

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> General Web Development >> Output Form Results to CSV
Page: [1]
 
clum1

 

Posts: 762
From: Glasgow, Scotland
Status: offline

 
Output Form Results to CSV - 5/7/2003 6:44:29   
Whilst this is asp-based code, I' m posting here because it took me so long to find an easily implemented way of doing this. Basically, I had a need to take some user input and save it as a downloadable .csv (Comma Separated Variables) file. To save others the hassle, I' m publishing it here...

(note, whilst I searched various sites - including this one - it was on w3schools.com that I finally found the stuff I needed.)


<%

' Allow the page to work on test machine or intranet server
' strWriteFolder exists because the server can not write to a UNC defined
' folder (strWritefolder is pointing to the same folder as strCurrentFolder

Dim host
Dim strCurrentFolder, strWriteFolder
host=lcase(request.servervariables(" HTTP_HOST" ))

SELECT CASE host
CASE " 6sy3b0j" ' my development machine
strCurrentFolder = (" \\6sy3b0j\pdrive\" )
strWriteFolder = (" \\6sy3b0j\pdrive\" )

CASE " intranet1" ' my intranet server name
strCurrentFolder = (" \\intranet1\shared\Project\CSV Files\" )
strWriteFolder = (" e:\shared\Project\CSV Files\" )

END SELECT

dim fs,tfile
set fs=Server.CreateObject(" Scripting.FileSystemObject" )
set tfile=fs.CreateTextFile(strWriteFolder & session(" GelPackID" ) & " .csv" )
tfile.WriteLine(" LOT NUMBER,LOT NAME,DATE STAMP,ID,PART NUMBER,PACK ID,POSITION" )
tfile.WriteLine Session(" LotNumber" ) & " ," & Session(" LotName" ) & " ," & Session(" DateStamp" ) & " ," & Session(" A1" ) & " ," & Session(" PartNumber" ) & " ," & Session(" GelPackID" ) & " ," & (" A1" )

tfile.close
set tfile=nothing
set fs=nothing
%>


Note, the first tfile.WriteLine sets up some column headers whilst the second one populates it with form data; you can use loops etc to cycle through your dataset.

I hope this is of some help to anyone else trying to do the same thing.

clum1

_____________________________

kenilweb.com; simple, effective web design

"So I said to the Gym instructor "Can you teach me to do the splits?" He said "How flexible are you?". I said "I can't make Tuesdays"."

Tim Vine
Page:   [1]
OutFront Discoveries

All Forums >> Web Development >> General Web Development >> Output Form Results to CSV
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts