Reputation: 3294
I'm trying to create an xls file from php using PHPExcel and fetching data from a mysql database. The sentece that gives me problem is something like "Corda Flessibile Antifiamma 1x16mm² NERO - € 1,21" If I get it from DB the PHPExcel write "FALSE" to the file. Code like this:
$result = mysql_query($query);
$array = mysql_fetch_array($result);
$string = $array['value'];
$activeSheet->setCellValue("B1", $string); //output => "FALSE"
BUT if I type it in the source code I get no problems and it is written to the file. COde like:
$activeSheet->setCellValue("B1", "Corda Flessibile Antifiamma 1x16mm² NERO - € 1,21"); //output correct => "Corda Flessibile Antifiamma 1x16mm² NERO - € 1,21"
Does anyone has ever encountered this same problem?
Upvotes: 1
Views: 2580
Reputation: 212522
PHPExcel expects strings to be UTF-8.
If you're pulling a non-UTF-8 character set value from the database, convert it to UTF-8 before writing it to PHPExcel.
Upvotes: 1