Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 546
Mohammad Masoudian Avatar asked Sep 18 '25 18:09

Mohammad Masoudian


1 Answers

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

if(is_numeric($column)) $column = '"'.$number.'"';
like image 100
Kai Avatar answered Sep 21 '25 10:09

Kai