[CSV] Génération d'un fichier CSV
Bonjour, j'ai fait un script PHP qui génère un fichier CSV ,et ça marche bien , mais quand je 'ouvre avec Calc OpenOffice 2.4.1 il regroupe le contenu en une seule colonne .
code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
$csv_data = "Produit;quantite ;nom;Ref;Code;date creation\n";
for($l=0;$l<sizeof($tablo);$l++){
$csv_data .= '"'.utf8_encode($tablo[$l][0]).'";"'.utf8_encode($tablo[$l][1]).'";"'.utf8_encode($tablo[$l][2]).'";"'.utf8_encode($tablo[$l][3]).'";"'.utf8_encode($tablo[$l][4]).'";"'.utf8_encode($tablo[$l][5]).'"'."\n";
}
$filename = "file_pdt.csv";
@$fhandle = fopen($filename,"w");
fwrite($fhandle,utf8_decode($csv_data));
fclose($fhandle);
header('Content-type: text/html; charset=utf-8');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$filename.'"');
//readfile($dir.$filename);
readfile($filename); |