PhpSpreadsheet/tests/data/Calculation/TextData
oleibman faf6d819c6
Keep Calculated String Results Below 32K (#2921)
* 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.
2022-07-04 08:30:46 -07:00
..
CHAR.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
CLEAN.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
CODE.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
CONCATENATE.php Keep Calculated String Results Below 32K (#2921) 2022-07-04 08:30:46 -07:00
DOLLAR.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
EXACT.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
FIND.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
FIXED.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
LEFT.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
LEN.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
LOWER.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
MID.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
NUMBERVALUE.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
OpenOffice.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
PROPER.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
REPLACE.php Keep Calculated String Results Below 32K (#2921) 2022-07-04 08:30:46 -07:00
REPT.php Keep Calculated String Results Below 32K (#2921) 2022-07-04 08:30:46 -07:00
RIGHT.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
SEARCH.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
SUBSTITUTE.php Keep Calculated String Results Below 32K (#2921) 2022-07-04 08:30:46 -07:00
T.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
TEXT.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
TEXTJOIN.php Keep Calculated String Results Below 32K (#2921) 2022-07-04 08:30:46 -07:00
TRIM.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
UPPER.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00
VALUE.php TextData - Minor Changes, Test Coverage (#2151) 2021-06-15 08:37:17 +02:00