首页 > 解决方案 > PHP:使用 phpexcel 读取 xls

问题描述

我无法读取 .xls 文件。值被读取为 null 和未知字符。该文件是从 ftp 服务器下载的,并且受到保护

$path = 'doc/20180719-ASK FIDC_EVOLUCAO_COTA.xls';
$inputFileType = PHPExcel_IOFactory::identify($path);

$reader = PHPExcel_IOFactory::createReader($inputFileType);
$reader->setReadDataOnly(true);
$reader->setInputEncoding('ISO-8859-1');
//$reader->setDelimiter("\t");

$excel = $reader->load($path);

var_dump($excel);
echo $inputFileType;

$writer = PHPExcel_IOFactory::createWriter($excel, 'CSV');
$writer->setUseBOM(true);
$writer->save('data.csv');

echo 'File saved to csv format';

转换后的文件如下图所示:

在此处输入图像描述

标签: phpexcelphpexcel

解决方案


推荐阅读