Save Form Data to XLS (Excel)

DarkLight's picture

He has: 287 posts

Joined: Oct 2007

Hi Guys, this is my first ever post here, and hopefully, not my last.
I am in Desperate need of some expert knowledge:

Here is what I have:

Online: HTML Page with form (Without any Properties)

Offline: Excel (XLS) Spreadsheet, with the following fields:
First Name , Last Name , Email Address

Here is what I need to do:

I want to get the HTML form to save submitted data directly to the xls file (which is offline), without any email activity.
I was thinking some kind of central database online, which would collect the data from the HTML Form, then uopn request, download directly into the xls.

Anyways, I will see what you make of this. Call me a brainless git if you want, but with all due respect, if everyone knew everything, then why are these forums here?
Naturally, I could do all this Manually, but then, where is the beauty of programming?
Thank you so much in advance, you will never know how much this will help my website. I am fed up of doing everything manually.
if you feel the need, please email me directly:
zdrastvuitye [at] hotmail.co.uk

All the best news here: https://newsbotnet.com

He has: 629 posts

Joined: May 2007

Well, I know nowt about the format of XLS files. But I do know that Excel accepts CSV files. That's Comma Separated Values.

It is relatively easy to parse the values from each of the form fields into a CSV file. You could the store it for later download, as you suggest, or even use sendmail on the server to send it to your email client for direct entry into Excel. Should be easy using any server-side scripting language. Check the Import feature of Excel to see how to import CSV.

The CSV file simply uses commas between each value, with one possible modification: if the value itself contains a comma, the value is wrapped in double quotes ("). Further, if there is already a double quote inside this new value, that double quote is doubled:

Example:
value 1: Jane
value 2: Doe
value 3: "Jane Doe"

Output: Jane,Doe,"""Jane Doe"" "

I hope this is not double Dutch!

Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;

DarkLight's picture

He has: 287 posts

Joined: Oct 2007

webwiz;225090 wrote: Well, I know nowt about the format of XLS files. But I do know that Excel accepts CSV files. That's Comma Separated Values.

It is relatively easy to parse the values from each of the form fields into a CSV file. You could the store it for later download, as you suggest, or even use sendmail on the server to send it to your email client for direct entry into Excel. Should be easy using any server-side scripting language. Check the Import feature of Excel to see how to import CSV.

The CSV file simply uses commas between each value, with one possible modification: if the value itself contains a comma, the value is wrapped in double quotes ("). Further, if there is already a double quote inside this new value, that double quote is doubled:

Example:
value 1: Jane
value 2: Doe
value 3: "Jane Doe"

Output: Jane,Doe,"""Jane Doe"" "

I hope this is not double Dutch!

Hey, thanks. Not exactly what i had in mind, but its a pretty good soution. You helped me out a lot here.

To anyone else, if you have any other info, excluding email transfer, plz post.

All the best news here: https://newsbotnet.com

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

Problem with xls is that it's a proprietary format, no-one but Microsoft really know the format. CSV on the other hand is dead simple: it's just a bunch of values, seperated by commas, and if you're running a computer with Office installed it'll open in Excel by default. The other beauty is that if you, or any of your customers, ever use an alternate office suite you (and your customers) will definitely be able to open the files. Trust me, it makes sense. Smiling

Next question is: what does your hosting company provide, in particular, are PHP and MySQL available? You need to get the values from the form and put them into a database. Next, you need to create another page (probably in a password protected directory) that creates a CSV file from the values stored in the database. This is a great little project to get you into programming (am assuming you're quite new to it). Smiling

Quote: Call me a brainless git if you want, but with all due respect, if everyone knew everything, then why are these forums here?

Quite right. Smiling
What we can't do around here is do all the work for you, or even tell you exactly how to do it. It would unfortunately take hours and we'd probably not even come up with exactly what you want anyway. We can tell you what you need to learn though:

  1. How to create a simple database schema to hold some values from your form (I'd suggest: phpMyAdmin for this, hopefully that comes with your hosting package).
  2. How to save values from a form to a database.
  3. How to make sure the values from the form aren't an attempt to hack your site and how to negate that risk: securing your form.
  4. How to create a password protected directory.
  5. How to use PHP to create a comma seperated list from a database and offer it to the user as a download.

This should get you started, sound ok? Let us know what your hosting company supports and I might be able to provide some good resources for you. If you have any questions along the way, make them as specific as possible, we'll be able to answer you better. Laughing out loud

a Padded Cell our articles site!

DarkLight's picture

He has: 287 posts

Joined: Oct 2007

JeevesBond;225157 wrote: Problem with xls is that it's a proprietary format, no-one but Microsoft really know the format. CSV on the other hand is dead simple: it's just a bunch of values, seperated by commas, and if you're running a computer with Office installed it'll open in Excel by default. The other beauty is that if you, or any of your customers, ever use an alternate office suite you (and your customers) will definitely be able to open the files. Trust me, it makes sense. Smiling

Next question is: what does your hosting company provide, in particular, are PHP and MySQL available? You need to get the values from the form and put them into a database. Next, you need to create another page (probably in a password protected directory) that creates a CSV file from the values stored in the database. This is a great little project to get you into programming (am assuming you're quite new to it). Smiling

Quite right. Smiling
What we can't do around here is do all the work for you, or even tell you exactly how to do it. It would unfortunately take hours and we'd probably not even come up with exactly what you want anyway. We can tell you what you need to learn though:

  1. How to create a simple database schema to hold some values from your form (I'd suggest: phpMyAdmin for this, hopefully that comes with your hosting package).
  2. How to save values from a form to a database.
  3. How to make sure the values from the form aren't an attempt to hack your site and how to negate that risk: securing your form.
  4. How to create a password protected directory.
  5. How to use PHP to create a comma seperated list from a database and offer it to the user as a download.

This should get you started, sound ok? Let us know what your hosting company supports and I might be able to provide some good resources for you. If you have any questions along the way, make them as specific as possible, we'll be able to answer you better. Laughing out loud

Ahh, this is great! This is what I wanted to know. Of course!!! the CSV, why did i not think of that! Thank you to everyone who has helped. I am not that new to programming, but i use things like c++ and older formats. Thanks again for all your help. I will follow these tips, and hopefully, be a couple of steps closer.
Please take a look at my website, tell me what you think...:
http://www.pcgenius.co.nr/

All the best news here: https://newsbotnet.com

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

Cool. Glad to be of help. If you get stuck on any particular point you know where to find us. Smiling

DarkLight's picture

He has: 287 posts

Joined: Oct 2007

My God I was a noob back then Laughing out loud LOL

They have: 3 posts

Joined: Sep 2010

Sorry for bumping this guys but i seem to have the same problem with DarkLight.
Ill start by introducing what i need.

What i can do:
A HTML website coded with CSS and HTML form.

What i cannot do:
This is abit hard to explain so ill write from 2 viewpoint
-----------------------------------------------------------------------------------------------------------------------------
The Client: Visited this website, OH a form to register a flea booth!, [registration in progress], Submit! Done...

The Server: Receive the registration, automatically turns it into an excel file and save it on the server.

Client 2: Visited this website, OH a form to register a flea booth!, [registration in progress], Submit! Done...

The Server: Receive the registration, update it to the 2nd row of the previous excel file and save it.
-----------------------------------------------------------------------------------------------------------------------------

So guys, what do i need to know or learn in order to do this? And DarkLight, i'm glad that you finally found your way out and thinking you was a noob back then! Hopefully ill be able to be like you in few years time.

They have: 1 posts

Joined: Jan 2013

Hi Everyone
I am totally self taught and have just joined this post and need a solution to the same problem. I have a PHP form with text boxes and some drop down boxes. Ideally, I want the data to post to an Excel database. I sort of understand GET and POST, but I don't know enough to develop a MySQL database for the data and without precise instructions can't set up a comma separated code. Eg, where do you write that code? On a separate html page or on php page? How does the php form and the CS code connect?
Would appreciate some assistance, guidance or where best to learn.

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

Please copy your post over to a new topic, many people (myself included) normally do not open threads that are 5 years old unless they are actively discussing the thread.

This thread is now closed due to age.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.