douhuan5073 2014-01-23 18:15
浏览 62
已采纳

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.

  • 写回答

2条回答 默认 最新

  • doukai2839 2014-01-23 18:17
    关注

    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);
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口