当我使用自动过滤器时,我在xls文件中遇到非数字值,我正在使用PHPExel包。 我的操作系统是ubantu 16.04。 使用Libreoffice查看文件。
My code
<?php
$objPHPExcel = new PHPExcel();
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Date');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Invoice');
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Client');
$row = 2;
foreach ($values['results'] as $value)
{
$objPHPExcel->getActiveSheet()->setCellValue('A'.$row,$columnFilter, date("d-m-Y", strtotime($value->payment_date)));
$objPHPExcel->getActiveSheet()->setCellValue('B'.$row, $value->invoice_number);
$objPHPExcel->getActiveSheet()->setCellValue('C'.$row, $value->client_name);
//Problem in below line when I use auto filter Im getting an non numeric value encountered
$objPHPExcel->getActiveSheet()->setAutoFilter('A1:C1');
$row++;
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Cutomer_Report.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
Error
A PHP Error was encountered
Severity: Warning
Message: A non-numeric value encountered
Filename: PHPExcel/Cell.php
Line Number: 803
答案 0 :(得分:2)
这是已知错误https://github.com/PHPOffice/PHPExcel/issues/1212 为了避免它,你可以
答案 1 :(得分:1)
就像 voter 一样,这是Github上的一个已知错误,并且不会得到修复,因为开发人员正在关注新的库。但是,您无需编辑和升级环境,而只需编辑一行并保留现有的实施即可。
如Github thread所示:
$endCoordinates = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::stringFromColumnIndex($iInc - 1));
$endCoordinates = PHPExcel_Cell::stringFromColumnIndex($iInc - 1);