这是为一个非政府组织完成的一项小工作,他们希望提供一个表单界面,并将表单值存储到Excel表格中。我目前知道的方法是需要通过HTML和PHP创建表单,然后将其转换为Excel电子表格。想知道是否有更短的方法来进一步简化工作。这与Google表格非常相似,但无需使用互联网即可实现。
file_put_contents
在此处阅读,执行以下操作:<?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."\n";
// Write the contents back to the file
file_put_contents($file, $current);
?>