PhpSpreadsheet:SUMIF 公式不起作用
PhpSpreadsheet : SUMIF formula is not working
预期的行为是什么?
我尝试添加公式 =SUMIF,但这不起作用。打开excel文件
时出现错误,公式被删除
当前的行为是什么?
当代码尝试计算公式时,这是错误的
重现步骤是什么?
sumif.xlsx : 检查此页面 : https://github.com/PHPOffice/PhpSpreadsheet/issues/892 下载 xlsx
<?php require 'vendor/autoload.php';
set_time_limit(-1);
//error_reporting(0);
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx");
$objPHPExcel = $reader->load("sumif.xlsx");
$objPHPExcel->setActiveSheetIndex(1);
for($count = 1 ; $count <= 10; $count++)
{
$objPHPExcel->getActiveSheet()->setCellValue('D'.$count, '=SUMIF(Résumé!D:D;B'.$count.';Résumé!F:F)');
}
$objPHPExcel->setActiveSheetIndex(0);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="paiement_'.date('Y-m-d').'.xlsx"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
/**/
$objWriter = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($objPHPExcel);
$objWriter->setPreCalculateFormulas(false);
$objWriter->save('php://output');
/**/
?>
哪些版本的 PhpSpreadsheet 和 PHP 受到影响?
PHP 7.0 和 PhpSpreadsheet 1.6.0
在公式字符串上,尝试使用 ,
而不是 ;
,如下所示:
'=SUMIF(Résumé!D:D,B'.$count.',Résumé!F:F)'
预期的行为是什么?
我尝试添加公式 =SUMIF,但这不起作用。打开excel文件
时出现错误,公式被删除当前的行为是什么?
当代码尝试计算公式时,这是错误的
重现步骤是什么?
sumif.xlsx : 检查此页面 : https://github.com/PHPOffice/PhpSpreadsheet/issues/892 下载 xlsx
<?php require 'vendor/autoload.php';
set_time_limit(-1);
//error_reporting(0);
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx");
$objPHPExcel = $reader->load("sumif.xlsx");
$objPHPExcel->setActiveSheetIndex(1);
for($count = 1 ; $count <= 10; $count++)
{
$objPHPExcel->getActiveSheet()->setCellValue('D'.$count, '=SUMIF(Résumé!D:D;B'.$count.';Résumé!F:F)');
}
$objPHPExcel->setActiveSheetIndex(0);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="paiement_'.date('Y-m-d').'.xlsx"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
/**/
$objWriter = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($objPHPExcel);
$objWriter->setPreCalculateFormulas(false);
$objWriter->save('php://output');
/**/
?>
哪些版本的 PhpSpreadsheet 和 PHP 受到影响?
PHP 7.0 和 PhpSpreadsheet 1.6.0
在公式字符串上,尝试使用 ,
而不是 ;
,如下所示:
'=SUMIF(Résumé!D:D,B'.$count.',Résumé!F:F)'