To output PHP data to an excel spreadsheet, PHP has great support in this area, and PHP can output a simple excel form in just a few simple sentences.
PHP code:
header ("Content-type: application / vnd.ms-excel");
header ("Content-Disposition: attachment; filename = users.xls");
echo "company name". "t";
echo "username". "t";
echo "password". "t";
echo "second-level domain name." "t";
echo "n";
foreach ($ result ['result'] as $ val) {
echo "$ val-> ComName". "t";
echo "$ val-> UserName". "t";
echo "$ val-> UserTruePw". "t";
echo emptyempty ($ val-> DoMainName)? '': ('http: //'.$val-> DoMainName.'. jiaomai.com '). "t";
echo "n";
}
?>
Pay attention to coding problems, because the form output is utf-8 encoding. I use the form of the form (table + tr + td) output when there garbled. . . . Because I page coding is GB2312, available iconv turn line, in order to prevent garbled themselves and engage in uncertainty, it is best to use the above output.