HTML到电子表格文件

This involves a small work for an NGO which wanted to give a form interface and then store the form values to an excel sheet.The method I know of now is that I need to create the form through html and php and then convert that to excel spreadsheet.Wondering if any other shorter approach would further ease the work.This is something very similar to google forms but to be achieved without using the Internet.

First off, if you need to accomplish this without using the internet, you will need to use either MAMP, WAMP, XAMPP or LAMP running locally on your machine.

Then I would use a FORM and PHP and place that information into a MySQL table.

From there you can create another PHP file to generate a report, with this the API: PHPExcel. Your Excel Sheet would be completely customizable with this API, and you could even style it exactly how you wanted. The bad thing with this approach, is that it will take some time to write the script to generate the report.

If this is a one time task, or you have the time to pull reports. You can use a MySQL Application to export your database as a CSV directly, like MySQL Workbench. This approach would take more time, and be less customizable.

There also is also a third approach, that doesn't involve a database, which would just require you to use PHP, and take the variables from the FORM and append it to a CSV file, you could use file_put_contents Read here, to do something like this:

<?php
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$phone_number = $_POST['phone'];

$file = 'spreadsheet.csv';

// Open the file to get existing content
$current = file_get_contents($file);

// Append a new person to the file
$current .= $fname.','.$lname.','.$phone_number."
";

// Write the contents back to the file
file_put_contents($file, $current);

?>

Google Spreadsheet's Forms would be perfect for this. You can create a form and save each response as a row in a Google Spreadsheet.