Outputting to Excel, how do I define different columns
Question
I am outputting data from my DB to Excel (has to be .xls format), but how do I tell Excel to put the data in to a new cell or to start a new line?
/** 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;
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow