PHP系列 | PHPexcel导入xls格式 ,提示错误:iconv(): Wrong charset, conversion from `CP936' to `UTF-8' i

导入xls格式(2003版本)时会报错提示错误信息

iconv(): Wrong charset, conversion from `CP936' to `UTF-8' is not allowed[/var/www/web/vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/String.php:490]

 解决办法:

if (self::getIsIconvEnabled()) {
    return iconv($from, $to, $value);
}

 修改为

if (self::getIsIconvEnabled()) {
    if ($to=='UTF-8' && $from=='CP936') {
        return iconv('UTF-8', 'latin1', $value);
    }
    return iconv($from, $to, $value);
}

 修改后

PHP系列 | PHPexcel导入xls格式 ,提示错误:iconv(): Wrong charset, conversion from `CP936' to `UTF-8' i

 

 

  

  

  

上一篇:PHP报错:iconv(): Detected an illegal character in input string


下一篇:php原生导出csv文件