PHPExcel UTF-8

Hi Experts,

How can I specify PHPExcel to use UTF-8?

Using PHPExcel I am trying to add chart, but as soon as I do I get "unreadable content" in Excel. With research I have found this Link.  To test this theory, I found that my generated file with PHPExcel and the Chart that open without issue on my iPad, but not on my Windows 7 x64 / Excel 2010.

How can I fix this issue?
APD TorontoSoftware DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
If the data that you are "passing/feeding" to PHPExcel is hard-coded in your php file, then most likely your php file is not encoded in UTF-8.  So try converting your file to UTF-8 first.  If your editor does not have a conversion feature, try downloading and installing Notepad++.  Open your source php file, and click on "Encoding > Convert to UTF-8 without BOM" and then save the file. Re-upload to the server and try again.

If the data that you are feeding onto PHPExcel originates from a database, then find out if the data is stored in UTF-8 already.  If so, then when you make the connection, make sure you specify the connection encoding as utf-8.
http://php.net/manual/en/mysqli.set-charset.php

If the data is not stored as utf-8, try to do the conversion by using CAST() at the time of doing the query:
https://dev.mysql.com/doc/refman/5.0/en/charset-convert.html

OR within php, try using mb_convert_encoding():
http://php.net/manual/en/function.mb-convert-encoding.php
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
APD TorontoSoftware DeveloperAuthor Commented:
In Notepad++ I checked, all m .php files are in UTF-8 without BOM

In phpMyAdmin, I see that all tables are utf8_general_ci

Does this cover your suggestions from above?

I thought this is a PHPExcel Setting, or something to do with the fact that I copying an existing file, opening the copied file, modifying it, then re-saving it?
0
Ray PaseurCommented:
Check "UTF-8 in Microsoft Applications" in this article.  Microsoft is particularly unhelpful in this regard.
http://www.experts-exchange.com/articles/11880/Unicode-PHP-and-Character-Collisions.html
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

APD TorontoSoftware DeveloperAuthor Commented:
How would I adapt this in PHPExcel - my scenario above?
0
Ray PaseurCommented:
It looks like you're swimming upstream to try using UTF-8 data with Microsoft applications.  You might want to ask "why do I need UTF-8?" and see if there is a way you can get get the job done without using UTF-8, perhaps by using a different encoding, then converting to UTF-8 only when required.  As noted, Microsoft is unhelpful, and the Stack reference is years old with little information.  What are the UTF-8 characters you need that cannot be represented in ISO-8859-1 or CP-1252?
0
APD TorontoSoftware DeveloperAuthor Commented:
It has nothing to do with characters. This issue originated when I created a chart in PHPExcel and as soon as I  added the following line I got unreadable content within Excel.

$excelWriterObj->setIncludeCharts(TRUE);

Within PHP I get no errors, and the file is created, but when I open the file in Excel 2010 under Windows 7 I get the above error and no chart.

When I open the same file on a MAC, there is no error and the chart is visible. The stack article suggesting UTF-8, and I also don't understand why, but I am just looking for a way to make the file work in Excel2010/Windows 7.
0
Ray PaseurCommented:
So you don't need PHPExcel to use UTF-8?  

Suggest you close this question and post a new one that says what you need.  I think if we have the original input data and a good picture of the desired output we might be able to suggest some good answers.  I thought this was about UTF-8, but maybe I was misunderstanding the problem.
0
APD TorontoSoftware DeveloperAuthor Commented:
But the stack solution was UTF8
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.