HTML Form to CSV or XLS

Posted on 2009-05-15
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?
Question by:UGSnow
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
LVL 54

Expert Comment

ID: 24401048
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.

Author Comment

ID: 24408808
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:


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!
LVL 54

Accepted Solution

b0lsc0tt earned 125 total points
ID: 24424319
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.

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"))
Set oFile = Nothing
Set oFS = Nothing

Open in new window

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users


Author Closing Comment

ID: 31582155
Thank you!
LVL 54

Expert Comment

ID: 24425202
I'm glad I could help.  Thanks for the grade, the points and the fun question.

Expert Comment

ID: 25241658
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.
LVL 54

Expert Comment

ID: 25242708
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.


Expert Comment

ID: 25242730
I did ope my question:

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

Thanks for giving it a look.
LVL 54

Expert Comment

ID: 25243052
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. :)


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

615 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