i am generating CSV,the file is generated very fine but i have problem in data in excel sheet.
i have phone number,time column.in browser its quite well but in csv file its not.
one row in browser= Unknown,03224250040,"2012-03-18 15:06:33",0,Outgoing
in csv file = Unknown 3.22E+09 ########## 0 Outgoing
but when i click on this 3.22E+09 in my csv it turns to this 03224250040 same for cell ####.
how can i add my column names too ??
this is my code
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=file.csv");
header("Pragma: no-cache");
header("Expires: 0");
function outputCSV($data) {
$outstream = fopen("php://output", "w");
function __outputCSV(&$vals, $key, $filehandler) {
fputcsv($filehandler, $vals);
}
array_walk($data, "__outputCSV", $outstream);
fclose($outstream);
}
outputCSV($array);
1 Answer