Mohammad Masoudian Mohammad Masoudian - 5 months ago 16
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 ->
    1E+12



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

Kai Kai
Answer

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

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