Reputation: 12047
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;
Upvotes: 0
Views: 1051
Reputation: 913
Try \t and \n,just like
echo join("\t", $array_keys)."\n";
\t for new column,\n for new row
Upvotes: 1