Problems with reading files with cyrilic symbols

Jul 29, 2008 at 1:26 PM
Hello, my site where i use the PHPExcel library is in windows-1251.
So when i`m entering values, i iconv() them from windows-1251 to utf-8 and they are displayed correctly.
But when i try to read the file back and make some changes..all the characters form the cyrilic alphabet are missing...and the cells containing them are empty.

So is there any possibility to change the incoming encoding or something...I`m really confused
Jul 29, 2008 at 1:53 PM
Is this happening with Excel 2007? Can you provide a link to some sample output showing the problem? Also, is would be helpful to see some of your code snippets.
Jul 29, 2008 at 2:00 PM
Edited Jul 29, 2008 at 2:02 PM
its for Excel5
so i`m adding values like this:

$objPHPExcel->getActiveSheet()->setCellValue('A3', iconv("windows-1251","utf-8", "Код на ИМП"));
$objPHPExcel->getActiveSheet()->setCellValue('B3', iconv("windows-1251","utf-8", "Регистрационен номер на ЛЗ"));
$objPHPExcel->getActiveSheet()->setCellValue('C3', iconv("windows-1251","utf-8", "Булстат"));
$objPHPExcel->getActiveSheet()->setCellValue('D3', iconv("windows-1251","utf-8", "Наименование на ЛЗ"));

then i save them, then i read them like this :

if (file_exists("/var/www/html/xls_files/$filename.xls")) {
        $objReader = PHPExcel_IOFactory::createReader('Excel5');
        $objPHPExcel = $objReader->load("/var/www/html/xls_files/$filename.xls");
        print $objPHPExcel->getActiveSheet()->getCell("A3")->getValue();
        print $objPHPExcel->getActiveSheet()->getCell("B3")->getValue();

When the values are simple english alphabet text, there is no problem...the print shows the data correctly...but when there`re cyrilic chars, they are not displayed
Also when the text is like 'Text Text "cyrilic chars here" Text2 Text2", when i read shows Text Text Text2 Text2

10x in advance if anyone comes up with any solution :)
Jul 29, 2008 at 4:57 PM
Yeah, there seems to be a problem with the Excel5 reader and non-ascii characters. It seems that there was no solution to a similar problem with Japanese characters:

So unless someone fixes the Excel5 reader then there may not be much hope.
Jul 30, 2008 at 7:03 AM
Use Excel2007 Reader and Writer every time when possible. Looks like Excel5 never be the same functional as Ex2007.
Jul 31, 2008 at 1:33 PM
Yeah, it seems that i`ll have to switch to the 2007 reader/writer.

Aug 1, 2008 at 4:25 AM
Ok, I tried to investigate the issue. Please try to locate in PHPExcel/Reader/Excel5.php the following line and change it from this

$this->_defaultEncoding = 'ISO-8859-1';

to this

$this->_defaultEncoding = 'UTF-8';

I am suspecting that this is a bug in the Excel5 reader. The PHPExcel object expects UTF-8 and not ISO-8859-1.

Aug 1, 2008 at 5:26 AM
Encoding is a big trouble when I try to extend PHPExcel.  Does it optional? Can I set Encoding at once (like $this->_defaultEncoding = 'UTF-8')  for all times instead of using iconv(1251 to UTF-8) every time?
Aug 18, 2008 at 4:16 AM
Update: Please note that the issue has been fixed in the latest source code.