Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Does not work with russia words #4266

Closed
1 task done
siarheipashkevich opened this issue Feb 5, 2025 · 1 comment
Closed
1 task done

[Bug]: Does not work with russia words #4266

siarheipashkevich opened this issue Feb 5, 2025 · 1 comment
Labels

Comments

@siarheipashkevich
Copy link
Contributor

siarheipashkevich commented Feb 5, 2025

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

  • Yes, it's still reproducable

What version of Laravel Excel are you using?

3.1.62

What version of Laravel are you using?

11.41.3

What version of PHP are you using?

8.3.16

Describe your issue

After upgrading two weeks ago I just found that my exports (with formula) do not work.

PHPOffice/PhpSpreadsheet#4203 (comment)

local.ERROR: preg_match(): failed executing "/^[^\*\:\/\\\?\[\]\+\-\% \'\^\&\<\>\=\,\;\#\(\)\"\{\}]+(\:[^\*\:\/\\\?\[\]\+\-\% \'\^\&\<\>\=\,\;\#\(\)\"\{\}]+)?\!\$?[A-Ia-i]?[A-Za-z]\$?\d+$/u": Malformed UTF-8 characters, possibly incorrectly encoded {"exception":"[object] (Composer\\Pcre\\PcreException(code: 4): preg_match(): failed executing \"/^[^\\*\\:\\/\\\\\\?\\[\\]\\+\\-\\% \\'\\^\\&\\<\\>\\=\\,\\;\\#\\(\\)\\\"\\{\\}]+(\\:[^\\*\\:\\/\\\\\\?\\[\\]\\+\\-\\% \\'\\^\\&\\<\\>\\=\\,\\;\\#\\(\\)\\\"\\{\\}]+)?\\!\\$?[A-Ia-i]?[A-Za-z]\\$?\\d+$/u\": Malformed UTF-8 characters, possibly incorrectly encoded at /Users/sergey/Herd/esupl-api/vendor/composer/pcre/src/PcreException.php:29)
[stacktrace]
#0 /Users/sergey/Herd/esupl-api/vendor/composer/pcre/src/Preg.php(37): Composer\\Pcre\\PcreException::fromFunction('preg_match', '/^[^\\\\*\\\\:\\\\/\\\\\\\\\\\\?\\\\...')
#1 /Users/sergey/Herd/esupl-api/vendor/composer/pcre/src/Preg.php(303): Composer\\Pcre\\Preg::match('/^[^\\\\*\\\\:\\\\/\\\\\\\\\\\\?\\\\...', '\"\\xD1', Array, 0, 0)
#2 /Users/sergey/Herd/esupl-api/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php(1097): Composer\\Pcre\\Preg::isMatch('/^[^\\\\*\\\\:\\\\/\\\\\\\\\\\\?\\\\...', '\"\\xD1')
#3 /Users/sergey/Herd/esupl-api/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php(1026): PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Parser->match('\"\\xD1')
#4 /Users/sergey/Herd/esupl-api/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php(1213): PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Parser->advance()
#5 /Users/sergey/Herd/esupl-api/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Worksheet.php(2729): PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Parser->parse('\"\\xD1\\x80\\xD1\\x83\\xD1\\x81\\xD1\\x81\\xD0\\xBA\\xD0\\xB8\\xD0\\xB9...')
#6 /Users/sergey/Herd/esupl-api/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Worksheet.php(531): PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Worksheet->writeDataValidity()
#7 /Users/sergey/Herd/esupl-api/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls.php(190): PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Worksheet->close()
#8 /Users/sergey/Herd/esupl-api/vendor/maatwebsite/excel/src/Writer.php(184): PhpOffice\\PhpSpreadsheet\\Writer\\Xls->save('/Users/sergey/H...')
#9 /Users/sergey/Herd/esupl-api/vendor/maatwebsite/excel/src/Writer.php(75): Maatwebsite\\Excel\\Writer->write(Object(App\\Exports\\InvoiceProductsTemplateExport), Object(Maatwebsite\\Excel\\Files\\LocalTemporaryFile), 'Xls')
#10 /Users/sergey/Herd/esupl-api/vendor/maatwebsite/excel/src/Excel.php(204): Maatwebsite\\Excel\\Writer->export(Object(App\\Exports\\InvoiceProductsTemplateExport), 'Xls')
#11 /Users/sergey/Herd/esupl-api/vendor/maatwebsite/excel/src/Excel.php(91): Maatwebsite\\Excel\\Excel->export(Object(App\\Exports\\InvoiceProductsTemplateExport), '\\xD0\\xA8\\xD0\\xB0\\xD0\\xB1\\xD0\\xBB\\xD0\\xBE\\xD0\\xBD \\xD0\\xB7...', 'Xls')
#12 /Users/sergey/Herd/esupl-api/vendor/maatwebsite/excel/src/Concerns/Exportable.php(30): Maatwebsite\\Excel\\Excel->download(Object(App\\Exports\\InvoiceProductsTemplateExport), '\\xD0\\xA8\\xD0\\xB0\\xD0\\xB1\\xD0\\xBB\\xD0\\xBE\\xD0\\xBD \\xD0\\xB7...', NULL, Array)

How can the issue be reproduced?

Add this method to your export:

    public function registerEvents(): array
    {
        return [
            AfterSheet::class => function (AfterSheet $event) {
                $worksheet = $event->sheet->getDelegate();

                $validation = $worksheet->getCell('B0')->getDataValidation();
                $validation->setType(DataValidation::TYPE_LIST);
                $validation->setErrorStyle(DataValidation::STYLE_STOP);
                $validation->setAllowBlank(false);
                $validation->setShowInputMessage(true);
                $validation->setShowErrorMessage(true);
                $validation->setShowDropDown(true);
                $validation->setFormula1('"слово, слово"'); // << russia words here

                $worksheet->setDataValidation('B2:B1500', clone $validation);
            },
        ];
    }

What should be the expected behaviour?

No any errors

@patrickbrouwers
Copy link
Member

Looks like this was fixed in phpspreadsheet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants