PHPExcel从ISO字符转换为utf8

时间:2018-03-17 14:54:47

标签: phpexcel

我无法从.xls文件中获取正确的字符  根据我在互联网上发现的内容,它似乎与编码有关,或者它与html的某些东西无法通过PHPexcel读取。它说PHPExcel读取文件必须是utf-8。你能给我一些关于如何获得正确编码或通过utf-8读取它的提示吗?

这是我的代码:

require_once 'Classes/PHPExcel.php';
    include 'Classes/PHPExcel/IOFactory.php';
    $pathgalleriadeclare = "C:\Users\Desktop\sample.xls";


try {


    $inputfiletype = PHPExcel_IOFactory::identify($pathgalleriadeclare);
    $objReader = PHPExcel_IOFactory::createReader($inputfiletype);
    $objReader->setInputEncoding('ISO-8859-1');
    utf8_encode($objReader);
    $objPHPExcel = $objReader->load($pathgalleriadeclare);

} catch(Exception $e){

    die('Error loading file "' .pathinfo($pathgalleriadeclare, PATHINFO_BASENAME).'": '.$e->getMessage());


}


$sheet = $objPHPExcel->getSheet(0);
$highRow = $sheet->getHighestRow();
$highColumn = $sheet->getHighestColumn();

for ($row = 7; $row <= $highRow; $row++){

    //REPORT
    $value = $objPHPExcel->getSheet(0)->getCell('A'.$row)->getValue();

    echo $value ;
    echo "<br />";

}


$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);
exit();

这是一个示例输出: enter image description here

0 个答案:

没有答案