1.下面是一个非常简单的例子,你可以复制下来运行就可以了,代码如下:
header('Content-Type: application/vnd.ms-excel;charset=gbk');
header('Content-Disposition: attachment;filename=test_' . time() . '.csv');
header('Cache-Control: max-age=0');
$list = array
(
"George,John,Thomas,USA",
"James,Adrew,Martin,USA",
);
$file = fopen('php://output', 'a');
foreach ($list as $line)
{
fputcsv($file,explode(',',$line));
}
fclose($file);