我想向 Excel 文件发送一个数组,这是一个包含不同类别的数组。
每个类别应进入一列。我编写的代码是将所有值发送到 Excel 上的一个字段。我在哪里弄错了?
$shop['id']=$id_array;
$shop['name']=$name_array;
$shop['cat1'] = $cat1;
$shop['cat2'] = $cat2;
$shop['cat3'] = $cat3;
$id_excel=implode(",",$shop['id']);
$name_excel=implode(",",$shop['name']);
$cat1_excel=implode(",",$shop['cat1']);
$cat2_excel=implode(",",$shop['cat2']);
$cat3_excel=implode(",",$shop['cat3']);
}
$filename ="cat.xls";
$contents = "$id_excel \t $name_excel \t $cat1_excel \t $cat2_excel \t $cat3_excel \t \n";
header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename='.$filename);
echo $contents;