mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-22 08:09:15 +00:00
Strip _xlfn. and _xlfs. In Formula Translations
Fix #3819. Excel can add these prefixes (basically invisible to end-user). Formula translation in PhpSpreadsheet fails when dealing with these unexpected prefixes, and, even if it handled it correctly, the unexpected prefixes confuse the users. I have changed to strip those prefixes when translating to a locale. This is probably not perfect, but is almost certainly good enough. I could easily add the same change when translating from a locale to English, but I don't think there's a good use case for that, so am opting not to do so for now. The documentation mentions `translateFormulaToLocale` and `translateFormulaToEnglish`. Neither of these exist; both names are preceded by an underscore. I have changed the code to match the documentation rather than vice versa, retaining deprecated versions of the underscored routines which merely invoke the non-underscored routines.
This commit is contained in:
@@ -47,7 +47,7 @@ class TranslationTest extends TestCase
|
||||
self::assertSame($expectedResult, $translatedFormula);
|
||||
|
||||
$restoredFormula = Calculation::getInstance()->_translateFormulaToEnglish($translatedFormula);
|
||||
self::assertSame($formula, $restoredFormula);
|
||||
self::assertSame(preg_replace('/_(xlfn|xlws)[.]/', '', $formula), $restoredFormula);
|
||||
}
|
||||
|
||||
public static function providerTranslations(): array
|
||||
|
||||
Reference in New Issue
Block a user