简体   繁体   中英

Export unicode data to excel in php

İ can export json data to excel with PHP. But I use ə,ü,ç,ı,ö and so on. This caracters don`t show. My code:

$file = "website_data_" . date('Ymd') . ".xls";
header("Content-Disposition: attachment; filename=\"$file\"");
header("Content-Type: application/vnd.ms-excel;   ");
$flag = false;
foreach($output as $row) {
  if(!$flag) { 
    $arr =  implode("\t", array_keys($row)) . "\r\n";
    $flag = true;
   }
   array_walk($row, __NAMESPACE__ . '\cleanData');
   $arr = $arr.implode("\t", array_values($row)) . "\r\n";
  }  
  echo   $arr; 

例子

Help me please

Change the header to

header('Content-Type: application/vnd.ms-excel; charset=utf-8');

to enforce using the UTF-8 character set.

When this does not work, please show what your filter does.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM