這篇文章主要介紹ThinkPHP6.0導(dǎo)出Excel的示例,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯(lián)公司是專業(yè)的桃源網(wǎng)站建設(shè)公司,桃源接單;提供成都做網(wǎng)站、成都網(wǎng)站制作,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行桃源網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊,希望更多企業(yè)前來合作!(1)安裝ThinkPHP6.0
composer create-project topthink/think tp2excel
(2)安裝Excel插件phpspreadsheet
composer require phpoffice/phpspreadsheet
(3)配置站點(diǎn)
(4)配置Nginx重寫
(5)啟動,查看首頁
(1)數(shù)據(jù)庫配置
(2)數(shù)據(jù)庫建表(略)
(1)引入Spread.php插件
(2)查詢數(shù)據(jù)并導(dǎo)出
<?php namespace app\controller; use app\BaseController; use think\facade\Db; use Tools\Spread; class Index extends BaseController { public function index() { return '<html><a href="/index/excel.html?limit=2000">導(dǎo)出Excel</a><html>'; } public function excel($limit = 10) { $expTableData = Db::table('b_demo')->limit($limit)->select(); $fileName = "IP地址導(dǎo)出"; $Excel['fileName']=$fileName.date('Y年m月d日-His',time());//or $xlsTitle $Excel['cellName']=['A','B','C','D']; $Excel['H'] = ['A'=>12,'B'=>22,'C'=>28,'D'=>38];//橫向水平寬度 $Excel['V'] = ['1'=>40,'2'=>26];//縱向垂直高度 $Excel['sheetTitle']=$fileName;//大標(biāo)題,自定義 $Excel['xlsCell']=[ ['id','編號'], ['start','開始IP'], ['end','結(jié)束IP'], ['disp','地區(qū)']]; Spread::excelPut($Excel,$expTableData); } }
(3)導(dǎo)出結(jié)果
以上是“ThinkPHP6.0導(dǎo)出Excel的示例”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
網(wǎng)站標(biāo)題:ThinkPHP6.0導(dǎo)出Excel的示例-創(chuàng)新互聯(lián)
文章位置:http://chinadenli.net/article0/cdhooo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營銷推廣、手機(jī)網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、響應(yīng)式網(wǎng)站、搜索引擎優(yōu)化、云服務(wù)器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容