fputcsv display leading zeros

后端 未结 4 2070
轮回少年
轮回少年 2021-01-04 17:57

I\'m using a php script to generate an excel CSV file from a result-set query. All works fine but when i read my excel file, I can not display leading zeros.

this is

4条回答
  •  有刺的猬
    2021-01-04 18:43

    Try casting it to string like:

    fputcsv($fp, (string) $val);
    

    OR, Opening XLS file will truncate leading 0 so try adding /t before zero to avoid 0 truncation while creating your row values.

提交回复
热议问题