I had a problem exporting data from mysql utf8 database to excel sheet with PHPExcel and saving Chinese characters. My mysql db is utf8 and contains a lot of Chinese characters in it, and I export this data to a multi-page xls file (excel5), and every export of Chinese characters turns into a "?". I tried utf8_encode () but this does not work for me. I also tried changing the output to excel2007, thinking that this would be a problem with excel5.
Is there a way to properly export Chinese characters? Should I make the whole utf8 php file? and if so, how can I do this?
Here is the part I come across:
$res2 = mysql_query("SHOW COLUMNS FROM ".$sheetnametemp); while($row2 = mysql_fetch_array($res2, MYSQL_NUM)) { $counter = 2; $cell = $coltemp; $cell .= $counter; $objPHPExcel->getActiveSheet()->SetCellValue($cell, $row2[0]); $result = mysql_query("SELECT * FROM ".$sheetnametemp); while($row = mysql_fetch_array($result)) { $counter++; $cell2 = $coltemp; $cell2 .= $counter; utf8_encode($row[$row2[0]]); echo "<br />"; $objPHPExcel->getActiveSheet()->SetCellValue($cell2,utf8_encode($row[$row2[0]])); }
I need to use these Chinese characters as this is a multilingual db directory, so changing it to English would not help. I am also currently on a Mac with Xampp, if this information is anyway useful.
source share