Excel5 convert strings to UTF-8

Topics: Developer Forum, User Forum
Aug 29, 2008 at 10:00 AM
I need read data from Excel5 sheet (not UTF-8 encoded) and automatically convert all string values to UTF-8 (database encoding).

I must utf8_encode() to all string. Is there possible to add property to Excel5Reader: outputEncoding ?
Aug 29, 2008 at 10:18 AM
Not sure I understand what you mean... Since PHPExcel version 1.6.3 Excel5 reader is outputting UTF-8 and if that is what you need then there should be no need to convert anything. Can you elaborate perhaps with an example?
Aug 29, 2008 at 10:38 AM
There is BIFF5 spreadsheet with non-UTF8 encoding.

All strings form spreadsheet must be converted to UTF-8 (encoding of destination database).

And there are many places to place this code:
$name = utf8_encode($sheet->getCellByColumnAndRow(1, $pRow)->getValue()); // utf8_encode can be another convert function, getValue() returns string value

Is there possible (I think yes) to automate this? For example:

$objReader = PHPExcel_IOFactory::createReader("Excel5");
$objReader->setOutputEncoding ('UTF_8');
$this->objPHPExcel = $objReader->load($fileName);

Now can simple use:
$name = $sheet->getCellByColumnAndRow(1, $pRow)->getValue();
Aug 29, 2008 at 11:06 AM
Ok, I understand... you are trying to read old BIFF5 spreadsheet. This may be causing the problem. Can you please send a sample file to "erik at phpexcel dot net" so I can check up on this problem.
Aug 29, 2008 at 1:54 PM
Thanks, I received the test files and confirmed the issue. A separate work item has been created.

Aug 29, 2008 at 2:31 PM
Solution for Excel/OpenOffice users: Save as Excel97-2003 file (BIFF8)

Solution for 1C: Enterprise 7.7 users: open in Excel or OpenOffice >=2.0.3 Infra-Resource Build and Save as Excel97-2003 file (BIFF8)
Aug 29, 2008 at 10:48 PM
Thanks for the information. The bug has now been fixed.