导出一个数组的数组来的Excell在PHP。 [英] Export an Array of Arrays to Excell in php.
本文介绍了导出一个数组的数组来的Excell在PHP。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在每个子数组的开头数组的数组是列其次,我要填充的整数列的标题。它看起来是这样的:
I have an Array of arrays at the beginning of each sub array is the header of the column followed by integers that I want to populate the column. It looks something like this:
Array ( [0] => Array ( [0] => How was the Food? [1] => 3 [2] => 4 ) [1] => Array ( [0] => How was the first party of the semester? [1] => 2 [2] => 4 [3] => 0 ) )
有没有办法打破了数组并把它导出到Excel?
Is there a way to break up the array and get it to export to Excel?
推荐答案
Excel可以直接打开csv文件...尝试
Excel can open csv file directly ... try
$array = Array (
0 => Array (
0 => "How was the Food?",
1 => 3,
2 => 4
),
1 => Array (
0 => "How was the first party of the semester?",
1 => 2,
2 => 4,
3 => 0
)
);
header("Content-Disposition: attachment; filename=\"demo.xls\"");
header("Content-Type: application/vnd.ms-excel;");
header("Pragma: no-cache");
header("Expires: 0");
$out = fopen("php://output", 'w');
foreach ($array as $data)
{
fputcsv($out, $data,"\t");
}
fclose($out);
这篇关于导出一个数组的数组来的Excell在PHP。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文