PHP Data needs to be output to an excel table. PHP supports this very well. PHP can output a simple excel table in just a few simple sentences.
PHP Data needs to be output to an excel table. PHP supports this very well. PHP can output a simple excel table 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 the encoding problem, because the table generally outputs UTF-8 encoding. Garbled characters appear when I output data in table form (table + tr + td .... Because my page code is GB2312 and can be converted to iconv, it is best to use the above method to output the code to prevent garbled characters.