PHPExcel写作问题

时间:2015-07-16 10:47:25

标签: php character-encoding phpexcel

我需要用mysql数据库中的数据编写一个.xls文件。一切都很好,除非有一个带有这个字符串的字段:“FALSE N |不要使用”。

在这种情况下,在特定单元格中,它只写入“FALSE N”并停在那里,而不写“|”以及之后的所有内容。

这个问题也出现在其他角色中,例如“我”

这是编写文件的代码段。

while (!$rs->EOF){  
    $objPHPExcel->setActiveSheetIndex(0)
                ->setCellValueExplicit('A'.$i, $rs->fields["nr_id"], PHPExcel_Cell_DataType::TYPE_STRING2)
                ->setCellValue('B'.$i, $rs->fields["descrizione"]) //this is the field that gives me the problem
                ->setCellValue('C'.$i, number_format($rs->fields["prezzo_eur"], 2, ",", ""));
$rs->Movenext();
$i++;
}

有没有办法只写一切?

它与html实体无关!

更新:我刚刚在utf8编码,一切都很好,感谢大家!

1 个答案:

答案 0 :(得分:1)

正如Mark Baker和问题的作者所说,解决方案是:

  

确保您存储在单元格中的所有字符串都是UTF-8