PHPOffice / PhpSpreadsheet

A pure PHP library for reading and writing spreadsheet files
https://phpspreadsheet.readthedocs.io
MIT License
13.33k stars 3.46k forks source link

PhpSpreadsheet generates a faulty Xls file when cells contain emojis #642

Closed rzds closed 1 year ago

rzds commented 6 years ago

This is an old story and it only happens when generating Xls files, it doesn't with Xlsx files. The same issue in the deprecated PHPExcel https://github.com/PHPOffice/PHPExcel/issues/1320 No one said why this is happening. The reader works fine with emojis. Isn't this issue fixable?

chandon commented 6 years ago

I've got the same issue

PowerKiKi commented 6 years ago

I believe Xls cannot support emoji. And even if it did, you really should use xlsx which has been around for more than 10 years already

xuanskyer commented 3 years ago

tks all , i got same q.:)

Daizygod commented 1 year ago

Still not supported 💀💀💀

oleibman commented 1 year ago

The problem is not restricted to emojis; it affects any text which uses characters not in the Unicode BMP. For Xls, Excel encodes its characters in UTF-16, generally a double-byte character set. But, for characters outside the BMP, UTF-16 uses "surrogates" to encode the character as 2 double-byte characters. Excel stores the number of 2-byte characters (so each non-BMP character counts as 2), but PhpSpreadsheet is storing the number of characters (so each non-BMP character counts as 1). Expect a fix in a day or two.

Daizygod commented 1 year ago

The problem is not restricted to emojis; it affects any text which uses characters not in the Unicode BMP. For Xls, Excel encodes its characters in UTF-16, generally a double-byte character set. But, for characters outside the BMP, UTF-16 uses "surrogates" to encode the character as 2 double-byte characters. Excel stores the number of 2-byte characters (so each non-BMP character counts as 2), but PhpSpreadsheet is storing the number of characters (so each non-BMP character counts as 1). Expect a fix in a day or two.

It`s really can be fixed? I've been thinking about switching to XLSWriter, I will wait thanks.