请用过PHPExcel插件的朋友指导一下。我用PHPExcel插件导入Excel数据。读取Excel文件后输出时 法文 字母中加重音符号字符为乱码。Excel表中字符串为:ELM327 OBD2 VGate de numérisation avancés Bluetooth outil d'analyse
读取后输出字符串为:ELM327 OBD2 VGate de num�risation avanc�s Bluetooth outil d'analyse
插件使用:
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('utf-8'); 此处不管我是设为utf-8还是设为ANSI都是乱码。

解决方案 »

  1.   

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    插入这个语句,还有你的数据库所有的地方编码都要用utf-8.
      

  2.   


    页面、数据库编码都为 utf-8;$data = new Spreadsheet_Excel_Reader();
    $data->setOutputEncoding('UTF-8');
    $data->read($file_name);
    $data_array = $data -> getExcelResult();
    print_r($data_array);读取Excel文件,print_r()输出。浏览器 -> 查看 -> 字符编码 -> Unicode(UTF-8)时显示为乱码。
        ELM327 OBD2 VGate de num�risation avanc�s Bluetooth outil d'analyse浏览器 -> 查看 -> 字符编码 -> 西方(ISO-8859-1)时显示正常。
        ELM327 OBD2 VGate de numérisation avancés Bluetooth outil d'analyse
    请问这样我该怎么转码呢?
    iconv('ISO-8859-1', 'UTF-8', $data_array) 
    上面的转法不可以。
      

  3.   

    $data = new Spreadsheet_Excel_Reader();
    $data->setInputEncoding('ANSI');
    $data->setOutputEncoding('UTF-8');
    $data->read($file_name);
    $data_array = $data -> getExcelResult();
    print_r($data_array);您这样试过了吗?