PHPOffice / PHPExcel

ARCHIVED
Other
11.46k stars 4.19k forks source link

parseFormula exception on mbstring named range #1197

Closed Dfred closed 7 years ago

Dfred commented 7 years ago

As confirmed by @MarkBaker, _PHPExcelCalculation::parseFormula() should handle multibyte named ranges. However the following call fails (cliché is a named range):

PHPExcel_Calculation::getInstance()->parseFormula('=cliché');

It throws a PHPExcel_Calculation_Exception with message

Formula Error: An unexpected error occured

PowerKiKi commented 7 years ago

Could you provide a Minimal, Complete, and Verifiable example of code that exhibits this issue without the use of external file please ?

Dfred commented 7 years ago

Is this good enough?

$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'kiki');
$objPHPExcel->addNamedRange( new PHPExcel_NamedRange(html_entity_decode('cliché'), $objPHPExcel->getActiveSheet(), 'A1'));
PHPExcel_Calculation::getInstance($objPHPExcel)->parseFormula(html_entity_decode('=cliché'));
PowerKiKi commented 7 years ago

thanks ! I can reproduce it even in PhpSpreadsheet:

require __DIR__ . '/vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\NamedRange;
use PhpOffice\PhpSpreadsheet\Calculation;

$objPHPExcel = new Spreadsheet();
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'kiki');
$name = html_entity_decode('cliché');
$objPHPExcel->addNamedRange(new NamedRange($name, $objPHPExcel->getActiveSheet(), 'A1'));
$res = Calculation::getInstance($objPHPExcel)->parseFormula('=' . $name);
var_dump($res);
Dfred commented 7 years ago

Good job with PhpSpreadsheet by the way, any release date in sight?

Dfred commented 7 years ago

@PowerKiKi Did you file a bug report on PhpSpreadsheet as well? If so, can you provide a link ?

PowerKiKi commented 7 years ago

No, I didn't file an issue on PhpSpreadsheet. I wish we could move issue across projects...

A beta release is planned "soon"...

Dfred commented 7 years ago

I copied this bug-report to PhpSpreadsheet, see it there: https://github.com/PHPOffice/PhpSpreadsheet/issues/179

PowerKiKi commented 7 years ago

Closing here