Php 输出到Excel时,如何定义不同的列
我正在将数据从数据库输出到Excel(必须是.xls格式),但如何告诉Excel将数据放入新单元格或开始一行Php 输出到Excel时,如何定义不同的列,php,excel,cells,Php,Excel,Cells,我正在将数据从数据库输出到Excel(必须是.xls格式),但如何告诉Excel将数据放入新单元格或开始一行 /** Set the headers */ header('Content-type: application/vnd.ms-excel'); header('Content-disposition: attachment;filename=referrals.xls'); /** Output the column headers (We don't need the ID, so
/** Set the headers */
header('Content-type: application/vnd.ms-excel');
header('Content-disposition: attachment;filename=referrals.xls');
/** Output the column headers (We don't need the ID, so drop it) */
foreach($referrals[0] as $key => $value) :
$array_keys[$key] = $key;
endforeach;
unset($array_keys['ID']);
echo join('???', $array_keys).'New row???';
/** Output the data */
foreach($referrals as $referral) : foreach($referral as $key => $value) :
$referral_array[$key] = $value;
endforeach;
unset($referral_array['ID']);
echo join('???', $referral_array).'New row???';
endforeach;
尝试\t和\n,就像
echo join("\t", $array_keys)."\n";
\t表示新列,\n表示新行您使用的Excel writer库是什么?您的数据实际上是什么样子的?不使用编写器-直接从数据库中以数组的形式获取数据,然后如上所述输出数据。我不需要任何漂亮的东西,只要一堆数据。