今天使用php导出cvs,在excel中打开,某一个字段是数字,长度高于16位结果就显示科学计数法
超过15位的话从第16位开始就用0代替了
查询了半天总算解决了就是在后面加上"\t"
$data[$key][1] = " ".$value[1]."\t";
// file name$filename = date('Ymd').'123.csv';header("Content-type: text/csv; charset=UTF-8");header("Content-Description: File Transfer");header("Content-Disposition: attachment; filename=$filename");header("Content-Transfer-Encoding: binary");$data = [['hhh','123321213313123123131'],['hh3123h','123321213313123123131'],['hh34h','12332121331312312313131231']];foreach ($data as $key =>$value){$data[$key][1] = " ".$value[1]."\t";}// file creationob_clean();$file = fopen('php://output', 'w');fwrite($file,"\xEF\xBB\xBF");$header = array("test1",'test2');fputcsv($file, $header);foreach ($data as $key=>$line){fputcsv($file,$line);}fclose($file);exit;