0

我正在将数据从我的数据库输出到 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 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;
4

1 回答 1

1

试试 \t 和 \n,就像

echo join("\t", $array_keys)."\n";

\t 表示新列,\n 表示新行

于 2012-01-18T11:19:10.337 回答