Juozas
Juozas

Reputation: 77

PHP writeexcel and UTF-8 support

Has anyone of you ever used php_writeexcel (http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/)?

I would like to know if there is an easy way to enable utf-8 support. php_writeexcel exports html to Microsoft Excel documents, yet it can't display certain characters:

http://pastebin.com/AgVpph7F

Perhaps I could solve this with some php functions?

Thanks for your help!

Upvotes: 2

Views: 3273

Answers (3)

Punchpudding
Punchpudding

Reputation: 11

For fields with special characters (eg french) I use utf8_decode() to get the special characters to show up correctly.

Upvotes: 1

Jon Hulka
Jon Hulka

Reputation: 1309

It isn't a perfect solution, but iconv will convert some of those characters.

http://www.php.net/manual/en/function.iconv.php

Depending how you want the unsupported characters to be handled:

iconv('UTF-8', 'ISO-8859-1//IGNORE','ėčščįęščūųüó');

output: üó

iconv('UTF-8', 'ISO-8859-1//TRANSLIT','ėčščįęščūųüó');

output: ??????????üó

Upvotes: 0

jmcnamara
jmcnamara

Reputation: 41574

Php_writeexcel is a port of the Perl module Spreadsheet::WriteExcel. However, the port is from a time when Unicode strings weren't supported in the underlying Excel file format.

Later (2.xx) versions of Spreadsheet::WriteExcel have native support for Unicode but they haven't been ported to PHP.

As such you won't be able to handle Unicode strings with php_writeexcel.

Upvotes: 0

Related Questions