Home  >  Article  >  Backend Development  >  Easily implement PHP output excel_PHP tutorial

Easily implement PHP output excel_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:39:57834browse

To output PHP data to an excel table, PHP has very good support in this regard. PHP can output a simple excel table with just a few simple sentences.

PHP code:

 header("Content-type:application/vnd.ms-excel");

header("Content-Disposition:attachment;filename=users.xls" );

echo "Company name"." ";

echo "Username"." ";

echo "password"." ";

echo "second-level domain name"." ";

echo " ";

foreach($result[result] as $val){

echo "$val->ComName"." ";

echo "$val->UserName"." ";

echo "$val->UserTruePw"." ";

echo emptyempty($val->DoMainName)?:(http://.$val->DoMainName..jiaomai.com)." ";

echo " ";

 }

 ?>

Pay attention to encoding issues, because tables are generally output in UTF-8 encoding. When I output it in tabular format (table+tr+td), garbled characters appear. . . . Because the encoding of my page is GB2312, I can use iconv to convert it. In order to prevent the garbled code from being messed up by myself, it is best to use the above method to output.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486264.htmlTechArticleTo output PHP data to an excel form, PHP has very good support in this regard. PHP only needs a few simple steps Sentence can output a simple excel table. PHP code: header(Content-type:applicati...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn