使用php将文件从表导出到excel


export file from table to excel using php

hi我是编程新手,我使用php。下面是我的.xls代码。我有一个表单,其中有三个按钮:添加搜索和"保存到excel"。此外,我还有一个表,其中显示了我的add按钮输出,该表已连接到我的数据库。现在我的问题是,当我点击"保存到excel"按钮时,我表单中的所有数据都会显示在excel中。我想要的是我表格中的表格只保存在我的excel中。不是我表格中的全部数据。如果我只能在这里发布图片,你可能会清楚地理解我。:谢谢

if (isset($_POST['download']))
{
$file="document_name" . date('Ymd') . ".xls";
header("Content-type: application/vnd.ms-excel");// file extension name
header("Content-Disposition: attachment; filename=$file");
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");;
header("Content-Disposition: attachment;filename=line_utilization_report.xls ");
header("Content-Transfer-Encoding: binary ");