Browse Source

Export csv file as utf8 see BT#10895

jmontoyaa 7 years ago
parent
commit
2a4ea89fd6
1 changed files with 3 additions and 5 deletions
  1. 3 5
      main/inc/lib/export.lib.inc.php

+ 3 - 5
main/inc/lib/export.lib.inc.php

@@ -42,10 +42,9 @@ class Export
         }
 
         $filePath = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.csv';
-
-        $writer = new CsvWriter();
-        $writer->setStream(fopen($filePath, 'w'));
-
+        $stream = fopen($filePath, 'w');
+        $writer = new CsvWriter(';', '"', $stream, true);
+        $writer->prepare();
         foreach ($data as $item) {
             if (empty($item)) {
                 $writer->writeItem([]);
@@ -75,7 +74,6 @@ class Export
         $file = new \SplFileObject($filePath, 'w');
         $writer = new ExcelWriter($file);
         $writer->prepare();
-
         foreach ($data as $row) {
             $writer->writeItem($row);
         }