I have a problem with PHPExcel library 1.7.9 creating a xlsx.
Im using fromArray method to fill a MySQL table into an xlsx, when i try to fill any cell with accents, the cell is filled as "FALSE".
This is my code:
$query="SELECT
Caso,
Etq_Amarilla,
Tipo,
Etiqueta,
'EC Sociedad',
ProveedorEscalado,
Proveedor_de_Mantenimiento,
organizativo,
OficinaPeople,
centro,
sociedad,
Tipo_Disp,
Fecha_y_hora_de_creacion,
Fecha_y_hora_de_cierre,
domicilio,
jcentro04,
analitico,
DTDT
from CdM_Diario where Dia='5'";
$datos=$mysqli->query($query);
$objPHPExcel->setActiveSheetIndex(4);
$objPHPExcel->getActiveSheet()->fromArray($cabecera,NULL,"A1");
$cont=2;
while($fila=$datos->fetch_assoc())
{
$objPHPExcel->getActiveSheet()->fromArray($fila,"pepe","A".$cont."");
$cont++;
}
$cont=2;
Solved with:
$mysqli->set_charset('utf8');
Thanks to Mark Baker
I know it's quite old, but I came across the same today and utf8_encode($row['field'])
worked for me.
PHPExcel works with UTF-8 charset, you need to use UTF-8 data or convert it before setting it to your object.
$mysqli->set_charset('utf8');
should do the trick.
credit to @Mark Baker
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With