Created
January 24, 2016 19:57
-
-
Save brahimmachkouri/82d7c53d30a8062c5a46 to your computer and use it in GitHub Desktop.
PHPExcel : Enregistrement CSV en ISO-8859-1, avec tabulation comme séparateur, pas de délimiteur, et retour à la ligne façon Windows.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// enregistrement du fichier | |
$objWriter = PHPExcel_IOFactory::createWriter($objWorksheet, 'CSV'); | |
$objWriter->setEnclosure(""); | |
$objWriter->setDelimiter("\t"); | |
$objWriter->setLineEnding("\r\n"); // cr lf (Windows) | |
ob_start(); | |
$objWriter->save('php://output'); | |
$excelOutput = ob_get_clean(); | |
// conversion en iso-8859-1, car PHPExcel genere de l'utf-8 | |
$f = mb_convert_encoding($excelOutput, 'iso-8859-1'); | |
$f = trim($f)."\r\n"; | |
file_put_contents('export.txt',$f); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment