CSV Export code:
Public Function Export_csv () {if ($id = $this->get_input (' resultid ') = = = ") {$this->msg (' parameter is incorrect '); } $result = Call_mod_func (' admin/activity_mod ', ' Get_result ', Array ($id)); $str = "name, email, 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 piece of code
Under Apple System, open only one column in Excel:
Under Windows System, there are 4 columns open in Excel:
How do I change this code? To be compatible with multiple systems?
"If separated by semicolons, it is normal under the Mac system, only one column under Windows"
Reply content:
CSV Export code:
Public Function Export_csv () {if ($id = $this->get_input (' resultid ') = = = ") {$this->msg (' parameter is incorrect '); } $result = Call_mod_func (' admin/activity_mod ', ' Get_result ', Array ($id)); $str = "name, email, 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 piece of code
Under Apple System, open only one column in Excel:
Under Windows System, there are 4 columns open in Excel:
How do I change this code? To be compatible with multiple systems?
"If separated by semicolons, it is normal under the Mac system, only one column under Windows"
Is this a difficult question? No one answered ....