I can't for the life of me figure this out at the moment but watch it be something blatantly obvious.
CSV Exports are working and are comma delimited. But MS Excel is refusing to column them correctly.
I have the headers like so:
header('Content-Encoding: UTF-8');
header("Content-type: text/csv; charset=UTF-8");
header("Content-Disposition: attachment; filename=" . $filename . ".csv");
And the code like so:
$contents = "Artist,Title,Presenter,Time Played\n";
while ($row = mysql_fetch_array($user_query)) {
$contents.= "\"" . $row['artist'] . "\",";
$contents.= "\"" . $row['title'] . "\",";
$contents.= "\"" . $row['presenter'] . "\",";
$contents.= "\"" . $row['timeplayed'] . "\"\n";
}
$contents_final = chr(255) . chr(254) . mb_convert_encoding($contents, "UTF-16LE", "UTF-8");
print $contents_final;
And it seems to work fine on my MS Excel machine, but I have used this machine for a lot of manual CSV work so it may be a change I've made there. For first installs, it's not separating by columns properly.
It still needs to be a CSV file though as a requirement. Any thoughts on how I can force Excel to read this properly without the user having to manually force the columns?
\r\ninstead of just\n