日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > php >内容正文

php

yii框架phpexcel

發(fā)布時(shí)間:2024/4/15 php 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 yii框架phpexcel 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
//控制器調(diào)用 $id=\Yii::$app->request->get('id');
????????$arr=\Yii::$app->exam->createCommand("select?*?from?`order`?INNER?JOIN?movie?on?`order`.movie_id=movie.id?where?`order`.id?in?($id)")->queryAll();
????????$strTable?='<table?width="500"?border="1">';
????????$strTable?.=?'<tr>';
????????$strTable?.=?'<td?style="text-align:center;font-size:12px;"?width="150px">訂單</td>';
????????$strTable?.=?'<td?style="text-align:center;font-size:12px;"?width="*">姓名</td>';
????????$strTable?.=?'<td?style="text-align:center;font-size:12px;"?width="*">電話</td>';
????????$strTable?.=?'<td?style="text-align:center;font-size:12px;"?width="*">預(yù)約時(shí)間</td>';
????????$strTable?.=?'<td?style="text-align:center;font-size:12px;"?width="*">預(yù)約座位</td>';
????????$strTable?.=?'<td?style="text-align:center;font-size:12px;"?width="*">預(yù)約電影</td>';
????????$strTable?.=?'</tr>';
????????foreach($arr?as?$key=>$val)
????????{
????????????$strTable?.=?'<tr>';
????????????$strTable?.=?'<td?style="text-align:center;font-size:12px;">'.$val['order_no'].'?</td>';
????????????$strTable?.=?'<td?style="text-align:center;font-size:12px;">'.$val['username'].'?</td>';
????????????$strTable?.=?'<td?style="text-align:center;font-size:12px;">'.$val['tel'].'</td>';
????????????$strTable?.=?'<td?style="text-align:center;font-size:12px;">'.$val['start_time'].'?</td>';
????????????$strTable?.=?'<td?style="text-align:center;font-size:12px;">'.$val['seatnum'].'?</td>';
????????????$strTable?.=?'<td?style="text-align:center;font-size:12px;">'.$val['name'].'?</td>';
????????????$strTable?.=?'</tr>';
????????}
????????$strTable?.='</table>';

????????//echo?'123';

????????$reportObj?=?new?PHPExcel();
????????$reportObj->setFileName('demo');
????????$reportObj->toDownload($strTable); //model里引用 <?php

namespace frontend\models;
//include $_SERVER['D3OCUMENT_ROOT'].'/PHPExcel/EXCEL/PHPExcel.php';
// include 'E:\www\WWW\advanced\common\widgets\PHPExcel\EXCEL\PHPExcel\Writer\Excel2007.php';
use yii\base\Model;

/**
?* This is the model class for table "country".
?*
?* @property string $code
?* @property string $name
?* @property integer $population
?*/
class PHPExcel extends Model
{

??? //文件名
??? private $fileName = 'user';

??? //構(gòu)造函數(shù)
??? public function __construct($fileName = '')
??? {
??????? $this->setFileName($fileName);
??? }

??? //設(shè)置要導(dǎo)出的文件名
??? public function setFileName($fileName)
??? {
??????? $this->fileName = $fileName;
??? }

??? //開始下載
??? public function toDownload($strTable)
??? {
??????? header("Content-type: application/vnd.ms-excel");
??????? header("Content-Type: application/force-download");
??????? header("Content-Disposition: attachment; filename=".$this->fileName."_".date('Y-m-d').".xls");
??????? header('Expires:0');
??????? header('Pragma:public');
??????? echo '<html><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'.$strTable.'</html>';
??? }

}

轉(zhuǎn)載于:https://www.cnblogs.com/zhanghuilong/p/6481010.html

總結(jié)

以上是生活随笔為你收集整理的yii框架phpexcel的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。