Can not rendered french text properly using PHPExcel

Topics: Developer Forum
Oct 8, 2009 at 4:58 PM

Hi,

Can anybody tell me how can I rendered french text in excel properly using PHPExcel?

I have tried it with utf8-encode, but some special chars are not rendered properly like----

A l’île exiguë où l'obèse jury mûr fête l'haï volapük, âne ex æquo au whist, ôtez ce vœu déçu.

 

Please help

Thanks

Sanjoy

Developer
Oct 9, 2009 at 11:15 AM

>> Can anybody tell me how can I rendered french text in excel properly using PHPExcel?

Just insert the values as UTF-8, it should be working. Example:

$objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A4', 'Miscellaneous glyphs')
            ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');

For future reference I have updated test 01simple.php located in the Tests folder to show an example of this.

Oct 10, 2009 at 10:57 AM
Edited Oct 10, 2009 at 11:00 AM

Thank you very much for your reply. I have tried it with utf8_encode and

I have successfully acheived my target in the way-

$row = 3;

$string = utf8_encode("A l’île exiguë où l'obèse jury mûr fête l'haï volapük, âne ex æquo au whist, ôtez ce vœu déçu.");

$excel

->getActiveSheet()->setCellValueByColumnAndRow(3, $row, $string);

All the special chars are handled properly, but only one letter containing î (i hat) is not rendered properly.

Otherwise its ok. How can I handle it.

Another question regarding the rich text formatting in excel. Suppose in MySql table, one column contain the string:- "<b>Test <i>Test</i>Test</b>",

When I want to write the string into excel with the formatting as an HTML page, its not working.

How can I resolved it. Please reply

Thanks

 

Developer
Oct 11, 2009 at 12:14 AM

>> All the special chars are handled properly, but only one letter containing î (i hat) is not rendered properly.

Avoid using utf8_encode(). There is no reason to use it. All it does is to slow down the script. Make sure your text editor is in UTF-8 mode. Type characters directly as UTF-8 in your PHP script. Download latest source code:

http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

Look at Tests/01simple.php how to do it properly. It also generates î (i hat)