Csv Export Code: {code ...} in the Apple system, this code only contains one column in excel: in windows, there are four columns in excel: How can I modify this code? To be compatible with multiple systems? [If they are separated by semicolons, the MAC system is normal. In windows, There is only...
Csv export code:
Public function export_csv () {if ($ id = $ this-> get_input ('resultid') = '') {$ this-> msg ('parameter error');} $ result = call_mod_func ('admin/activity_mod ', 'Get _ result', array ($ id )); $ str = "name, email address, mobile phone number ". PHP_EOL; $ str = iconv ('utf-8', 'gb2312', $ str); // Chinese transcoding foreach ($ result ['rows '] as $ row) {$ name = iconv ('utf-8', 'gb2312', $ row ['name']); $ email = $ row ['email ']; $ mobile = $ row ['mobile']; $ weixinid = iconv ('utf-8', 'gb2312 ', $ row ['weixinid']); $ str. = $ name. ','. $ email. ','. $ mobile. ','. $ weixinid. PHP_EOL;} $ filename = date ('ymd', gettime ()). '.csv '; // set the file name header ("Content-type: text/csv"); header ("Content-Disposition: attachment; filename = ". $ filename); header ('cache-Control: must-revalidate, post-check = 0, pre-check = 0'); header ('expires: 0 '); header ('pragma: public '); echo $ str ;}
This Code
In the Apple system, only one column is opened in excel:
In windows, there are four columns opened in excel:
How can I modify this code? To be compatible with multiple systems?
[If they are separated by semicolons, the MAC system is normal and windows has only one column]
Reply content:
Csv export code:
Public function export_csv () {if ($ id = $ this-> get_input ('resultid') = '') {$ this-> msg ('parameter error');} $ result = call_mod_func ('admin/activity_mod ', 'Get _ result', array ($ id )); $ str = "name, email address, mobile phone number ". PHP_EOL; $ str = iconv ('utf-8', 'gb2312', $ str); // Chinese transcoding foreach ($ result ['rows '] as $ row) {$ name = iconv ('utf-8', 'gb2312', $ row ['name']); $ email = $ row ['email ']; $ mobile = $ row ['mobile']; $ weixinid = iconv ('utf-8', 'gb2312 ', $ row ['weixinid']); $ str. = $ name. ','. $ email. ','. $ mobile. ','. $ weixinid. PHP_EOL;} $ filename = date ('ymd', gettime ()). '.csv '; // set the file name header ("Content-type: text/csv"); header ("Content-Disposition: attachment; filename = ". $ filename); header ('cache-Control: must-revalidate, post-check = 0, pre-check = 0'); header ('expires: 0 '); header ('pragma: public '); echo $ str ;}
This Code
In the Apple system, only one column is opened in excel:
In windows, there are four columns opened in excel:
How can I modify this code? To be compatible with multiple systems?
[If they are separated by semicolons, the MAC system is normal and windows has only one column]
This problem is very difficult? No answer ....