<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                在 Laravel 5 中使用 Laravel Excel 實現 Excel文件導入導出功能 ----需進行安裝&配置 使用laravel進行excel導出 - 定義路由 - 鏈接數據庫(.env config-database.php) - 創建模型&控制器 ~~~ <?php namespace App\Http\Controllers; use App\Models\MemberInfo; use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller; use Excel; class MemberInfoController extends Controller{ //打印member_info表中數據 public function export(){ //取回要打印的數據 $memberinfos = MemberInfo::all(); //聲明一個空數組并存入置頂欄備注信息 $celldata = []; $celldata[] = ['id','花名','真名','入職時間','電話號碼']; //將需要打印的數據字段 id nickname name jobtime job phone 賦值給變量 foreach ($memberinfos as $key=>$memberinfo){ $id = $memberinfo->id; $nickname = $memberinfo->nickname; $name = $memberinfo->name; $jobtime = $memberinfo->jobtime; $phone = $memberinfo->phone; $celldata[] = [$id,$nickname,$name,$jobtime,$phone]; } Excel::create('用戶詳情',function($excel) use ($celldata){ $excel->sheet('score', function($sheet) use ($celldata){ $sheet->rows($celldata); }); })->export('xls'); } } ~~~ 參考文檔:http://laravelacademy.org/post/2024.html 優化后: ~~~ <?php namespace App\Http\Controllers; use App\Models\MemberInfo; use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller; use Excel; class MemberInfoController extends Controller{ //打印member_info表中數據 public function export(){ //取回要打印的數據(指定字段)并轉成數組 $memberinfos = MemberInfo::all(['id','nickname','name','jobtime','phone'])->toArray(); //將需要打印的數據字段 id nickname name jobtime job phone 賦值給變量 $celldata = [['id','花名','真名','入職時間','電話號碼']]; //合并數組添加分欄置頂備注 $celldata = array_merge($celldata,$memberinfos); Excel::create('用戶詳情',function($excel) use ($celldata){ $excel->sheet('score', function($sheet) use ($celldata){ $sheet->rows($celldata); $sheet->setWidth(['D'=>100]); //設置單元格樣式 $count = count($celldata); $sheet->cells("B1:B$count", function($cells) { $cells->setFontWeight('bold'); }); }); })->export('xls'); } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看