PhpSpreadsheet: формула SUMIF не работает - PullRequest
0 голосов
/ 03 марта 2019

Какое поведение ожидается?

Я попытался добавить формулу = 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$2:D$22;B'.$count.';Résumé!F$2:F$22)');
}

$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

...