mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-23 14:12:10 +00:00
9bd828e25d
Fix #4061. CONCATENATE, which has slightly different behavior than CONCAT, and which MS has deprecated for that reason, behaves in an unexpected way when a cell range is presented to it and the spreadsheet does not allow for array results. This would almost certainly occur only for Legacy spreadsheets, but such is what was presented in the issue. The code is changed so that when an array of cells is presented to CONCATENATE, and RETURN_ARRAY_AS_VALUE is in effect, the array will be treated as if it were wrapped in the SINGLE pseudo-function (which is what Excel does by somewhat mysteriously prefixing the cell range with `@`). This is a niche case. This one stands out because of its deprecation and replacement function. It is possible that other functions exhibit this behavior. I have made no attempt to identify others. A similar approach can probably be applied if issues are raised for others.
40 lines
699 B
PHP
40 lines
699 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
|
|
|
return [
|
|
[
|
|
'ABCDEFGHIJ',
|
|
'ABCDE',
|
|
'FGHIJ',
|
|
],
|
|
[
|
|
'123',
|
|
1,
|
|
2,
|
|
3,
|
|
],
|
|
[
|
|
'Boolean-TRUE',
|
|
'Boolean',
|
|
'-',
|
|
true,
|
|
],
|
|
'no arguments' => ['exception'],
|
|
'result just fits' => [
|
|
// Note use Armenian character below to make sure chars, not bytes
|
|
str_repeat('Ԁ', DataType::MAX_STRING_LENGTH - 5) . 'ABCDE',
|
|
'A3',
|
|
'ABCDE',
|
|
],
|
|
'result too long' => [
|
|
'#CALC!',
|
|
'A3',
|
|
'abc',
|
|
'def',
|
|
],
|
|
'propagate DIV0' => ['#DIV/0!', '1', 'A2', '3'],
|
|
];
|