如何将几个选定的表导出到单个excel文件中,每个表都有一张工作表?
下面是我目前的代码。
$con = mysqli_connect("localhost","root","","test1");
if(isset($_POST["download"]))
{
header('Content-Type: text/csv; charset=windows-1257');
header('Content-Disposition: attachment; filename=TEST.csv');
$output = fopen("php://output", "w");
fputcsv($output, array( 'ID', 'Name','type'));
$query = "SELECT * from table1";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_assoc($result))
{
fputcsv($output, $row);
}
fclose($output);
}
暂无答案!
目前还没有任何答案,快来回答吧!