PHP Series | PHPexcel import xls format, an error: iconv (): Wrong charset, conversion from `CP936 'to` UTF-8' is not allowed

Will get an error an error message when you import xls format (2003 version)

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

 Solution:

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

 change into

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

 Modified

 

 

  

  

  

Guess you like

Origin www.cnblogs.com/tinywan/p/11574206.html