Ken
Ken

Reputation: 11

special character in php array and then insert into excel using phpexcel

I need to put in the small "TM" in php array and then insert into excel file using phpexcel. However, the excel generated shows the cell as "FALSE" and not "ABC™ 1". May I know how can I put in the small "TM" in php array and pass it into excel file using phpexcel? Below are the current code.

$matchPattern = array
    array("ABC™ 1","ABC","ABC"),
    array("XYZ","XYZ","XYZ")
);

and then insert into excel with phpexcel

$objPHPExcel->getActiveSheet()->fromArray($matchPattern, null, 'A1');

Upvotes: 0

Views: 989

Answers (1)

ChristianF
ChristianF

Reputation: 2061

This is probably an encoding issue.

It is highly recommended that you make 100% sure you're using UTF-8 with PHP, for all steps of the production. This will save you a lot of headaches in the long run.

However, some applications doesn't play too nicely with UTF-8, and expects a different charset out of the box. For these cases you can use mb_convert_encoding() to change from UTF-8 to the charset said application accepts.
In MS-Office the "safe" charset depends upon the local Office installation, but going for "iso-8859-1" is generally the safest bet. Just make sure you mark select the charset used in the Excel-document as well, if possible.

Upvotes: 0

Related Questions