Solved

HTML Form to CSV or XLS

Posted on 2009-05-15
9
666 Views
Last Modified: 2012-05-07
I have an HTML form that records 50 or so fields.

When submitted, I would like the form to email a CSV file, or XLS file to a specific email address for import into another application.

My limitations are that I can only use Javascript, HTML or ASP...  no .NET or PHP...  The environment I'm working in will not support this...

Does anyone have any suggestions on how this could be completed?
0
Comment
Question by:UGSnow
  • 5
  • 2
  • 2
9 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
ASP can do it.  Provide details on the form like field names (i.e. the html).  Maybe do just a small form with 5 fields if you want detailed code.  You also need to find out what mail object you can use.  The server could have a few different ones.  Your web host provider or server admin should be able to provide that info (or at least the OS of the server).  The type of file to make will be a CSV file since an XLS file can't really be made just with ASP and the web server.  A 3rd party object is needed to create a real Excel file.
Keep in mind that the form info should be validated by the ASP code too.  You don't want to get invalid or even harmful info.  You will also want to take steps to prevent this ASP script from being abused by bots, etc that will "autosubmit" to it.
bol
0
 

Author Comment

by:UGSnow
Comment Utility
Thanks bol

Can you provide a quick code snippet on how to generate the CSV file?  CSV works best, I was just thinking XLS would be easier, but apparently not :)

Lets say that I have the following form fields:

Name
Age
Weight
Phone
Email

but I only want Name, Phone and Email to be included in the CSV...  Is this something that can be done?   Server OS is Windows Server 2008.

No need to worry about bot useage at this point as this form will be available to authenticiated members only.  

Thanks so much for your help... Looking forward to a solution!
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 125 total points
Comment Utility
The basics for just this part of the code are below in the snippet then.  I added a couple of notes.  One key thing is the file will be created or overwritten by the CreateTextFile line.  If you don't want to overwrite the file then you just want to make a small change to that line (true becomes false) and test to see if the file exists firsts (so you only run the code if the file DOESN'T exist).
Let me know how that helps or if you have a question.
bol

Set oFS = Server.CreateObject("Scripting.FileSystemObject")

Set oFile = oFS.CreateTextFile("c:\inetpub\wwwroot\filename.csv", true)

oFile.WriteLine ("Name,Phone,Email")

' code to get recordset results for the csv file's contents

'   the recordset object is called rs in my code below

'   fields are named as I have above in the "header row"

'   none of the field values or header stuff is in quotes right now ...

'     but that can be added if required

While NOT rs.EOF

    oFile.WriteLine (rs("Name") & "," & rs("Phone") & "," & rs("Email"))

    rs.MoveNext

Wend

oFile.Close

Set oFile = Nothing

Set oFS = Nothing

Open in new window

0
 

Author Closing Comment

by:UGSnow
Comment Utility
Thank you!
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
I'm glad I could help.  Thanks for the grade, the points and the fun question.
bol
0
 
LVL 2

Expert Comment

by:Denver_IT
Comment Utility
I am trying to do the same things however I need to know what type of action I need to take with the ASP web page form.  Do I get or put?  Also the code you listed in this question, do I create a VBS file with that and put/get to it?

Thanks for the assistance.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
Have you opened your own question for this?  If not then please do.  Feel free to use the "ask a related question" link that is right above the box to type the comment you want to post here.  It will help you ask a new question but also alert all the participants of the original question of your new one.  If you have already opened a new question for this then please post its URL here in a comment.  I will be glad to look at it and try to help.

Don't forget to include details and a good title in your related question.  From what you said above I would also ask you clarify what you mean by get/put.  If you have a question about opening a new question then let me know.  I am glad this was helpful and hope I can also help you with your issue.

bol
0
 
LVL 2

Expert Comment

by:Denver_IT
Comment Utility
I did ope my question:  http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_24699767.html

The Title is: Take ASP web page form data and create a CSV

Thanks for giving it a look.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
It looks like you already got your answer.  If not or I looked at the wrong question then let me know.  Otherwise glad to see you got the help you needed and that this could be some help too. :)

bol
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now