mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-22 14:34:48 +00:00
faf6d819c6
* Keep Calculated String Results Below 32K This is the result of an investigation into issue #2884 (see also PR #2913). It is, unfortunately, not a fix for the original problem; see the discussion in that PR for why I don't think there is a practical fix for that specific problem at this time. Excel limits strings to 32,767 characters. We already truncate strings to that length when added to the spreadsheet. However, we have been able to exceed that length as a result of the concatenation operator (Excel truncates); as a result of the CONCATENATE or TEXTJOIN functions (Excel returns #CALC!); or as a result of the REPLACE, REPT, SUBSTITUTE functions (Excel returns #VALUE!). This PR changes PhpSpreadsheet to return the same value as Excel in these cases. Note that Excel2003 truncates in all those cases; I don't think there is a way to differentiate that behavior in PhpSpreadsheet. However, LibreOffice and Gnumeric do not have that limit; if they have a limit at all, it is much higher. It would be fairly easy to use existing settings to differentiate between Excel and LibreOffice/Gnumeric in this respect. I have not done so in this PR because I am not sure how useful that is, and I can easily see it leading to problems (read in a LibreOffice spreadsheet with a 33K cell and then output to an Excel spreadsheet). Perhaps it should be handled with an additional opt-in setting. I changed the maximum size from a literal to a constant in the one place where it was already being enforced (Cell/DataType). I am not sure that is the best place for it to be defined; I am open to suggestions. * Implement Some Suggestions ... from @MarkBaker.
117 lines
2.7 KiB
PHP
117 lines
2.7 KiB
PHP
<?php
|
||
|
||
return [
|
||
[
|
||
'QWDFGYUIOP',
|
||
'QWERTYUIOP',
|
||
'ERT',
|
||
'DFG',
|
||
],
|
||
[
|
||
'Mxrk Bxker',
|
||
'Mark Baker',
|
||
'a',
|
||
'x',
|
||
],
|
||
[
|
||
'Mxrk Baker',
|
||
'Mark Baker',
|
||
'a',
|
||
'x',
|
||
1,
|
||
],
|
||
[
|
||
'Mark Bxker',
|
||
'Mark Baker',
|
||
'a',
|
||
'x',
|
||
2,
|
||
],
|
||
[
|
||
'Mark Bakker',
|
||
'Mark Baker',
|
||
'k',
|
||
'kk',
|
||
2,
|
||
],
|
||
[
|
||
'Mark Baker',
|
||
'Mark Baker',
|
||
'x',
|
||
'a',
|
||
1,
|
||
],
|
||
[
|
||
'Ενα δύο αρία αέσσερα πέναε',
|
||
'Ενα δύο τρία τέσσερα πέντε',
|
||
'τ',
|
||
'α',
|
||
],
|
||
[
|
||
'Ενα δύο τρία αέσσερα πέντε',
|
||
'Ενα δύο τρία τέσσερα πέντε',
|
||
'τ',
|
||
'α',
|
||
2,
|
||
],
|
||
[
|
||
'Ενα δύο τρία ατέσσερα πέντε',
|
||
'Ενα δύο τρία τέσσερα πέντε',
|
||
'τ',
|
||
'ατ',
|
||
2,
|
||
],
|
||
'Unicode equivalence is not supported' => [
|
||
"\u{0061}\u{030A}",
|
||
"\u{0061}\u{030A}",
|
||
"\u{00E5}",
|
||
'x',
|
||
],
|
||
'Multibytes are supported' => [
|
||
'x',
|
||
"\u{00E5}",
|
||
"\u{00E5}",
|
||
'x',
|
||
],
|
||
'no arguments' => ['exception'],
|
||
'one argument' => ['exception', 'a'],
|
||
'two arguments' => ['exception', 'a', 'b'],
|
||
'negative instance' => ['#VALUE!', 'abcdefg', 'def', 123, -1],
|
||
'non-numeric instance' => ['#VALUE!', 'abcdefg', 'def', 123, 'xyz'],
|
||
'null instance' => ['abc123g', 'abcdefg', 'def', 123],
|
||
'0 instance' => ['#VALUE!', 'abcdefg', 'def', 123, 0],
|
||
'1 instance' => ['abc123g', 'abcdefg', 'def', 123, 1],
|
||
'past last instance' => ['abcdefg', 'abcdefg', 'def', 123, 2],
|
||
'bool false instance' => ['#VALUE!', 'abcdefg', 'def', '123', false],
|
||
'bool true instance' => ['#VALUE!', 'abcdefg', 'def', '123', true],
|
||
'bool text' => ['FA-SE', false, 'L', '-'],
|
||
'propagate REF' => ['#REF!', '=sheet99!A1', 'A', 'x'],
|
||
'propagate DIV0' => ['#DIV/0!', 'hello', '=1/0', 1, 'x'],
|
||
'string which just sneaks in' => [
|
||
str_repeat('A', 32766) . 'C',
|
||
str_repeat('A', 32766) . 'B',
|
||
'B',
|
||
'C',
|
||
],
|
||
'string which overflows' => [
|
||
'#VALUE!',
|
||
str_repeat('A', 32766) . 'B',
|
||
'B',
|
||
'CC',
|
||
],
|
||
'okay long string instance' => [
|
||
'AAAAB' . str_repeat('A', 32762),
|
||
str_repeat('A', 32767),
|
||
'A',
|
||
'B',
|
||
5,
|
||
],
|
||
'overflow long string instance' => [
|
||
'#VALUE!',
|
||
str_repeat('A', 32767),
|
||
'A',
|
||
'BB',
|
||
5,
|
||
],
|
||
];
|