phpexcel导出文件内容空白或错误原因之一(存在乱码字符)的解决办法
public function illegal_unicode($str='') { $txtcode=explode('\u',str_replace("\"","",json_encode($str))); foreach ($txtcode as $kt=>$vt){ if($vt>="d800" && $vt<"df00"){ $txtcode[$kt]="ff1f"; } } return json_decode("\"".join('\u',$txtcode)."\""); } }
在php中引入上方函数,直接将emoji等编码范围在/ud800-/udf00的字符替换成“??”,已实现excel中不存在乱码字符的可能,最终实现文件正常输出!