Mohammad Masoudian Mohammad Masoudian - 1 year ago 61
SQL Question

numbers issue after export mysql data to CSV

when i get data from database and export it as a csv file i have following issues :

  • the leading zero of the numbers dosnt show

  • big numbers shows like this ->

how to force MS Excel to show all of my data as string by PHP

Kai Kai
Answer Source

You can use double quotes contain the numbers, like this:

if(is_numeric($column)) $column = '"'.$number.'"';