亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何僅將 Laravel Blade 表視圖中的特定列導出到 Ecxel 文件?

如何僅將 Laravel Blade 表視圖中的特定列導出到 Ecxel 文件?

PHP
繁花如伊 2023-08-11 16:51:33
所以我在刀片視圖文件上有一個表,我已成功將其導出到 Excel 文件中?,F在我想導出而不導出“操作”列。我該怎么做?我在下面附上了我的代碼和刀片文件,它工作得很好。我只想導出除操作列之外的所有內容,因為它包含用于數據庫操作的按鈕這是我的出口類別代碼:public function view(): View{    return view ('ims.view_inventory_history_table', [        'data' => inbound_history::all()        ]);}public function headings(): array{    return [        'ID',        'Warehouse',        'SKU',        'Child SKU',        'Units',        'Invoice No.',        'Container No.',        'Entry Date'    ];}/** * @return array */public function registerEvents(): array{    return [        AfterSheet::class    => function(AfterSheet $event) {            $cellRange = 'A1:W1'; // All headers            $event->sheet->getDelegate()->getStyle($cellRange)->getFont()->setSize(14);        },    ];}}這是我的控制器功能:public function export_view(){    return Excel::download(new inboundHistory(), 'inboundHistory.xlsx');}這是我的路線:Route::Get('inbound_history/export_view' ,'imsController@export_view')->name('inbound_history.export_view');
查看完整描述

1 回答

?
12345678_0001

TA貢獻1802條經驗 獲得超5個贊

我不知道我是否正確理解了一切,但你為什么不做這樣的事情:


$isView當您想要為用戶創建視圖時,將附加變量傳遞到您的刀片模板,例如。


在 Blade.php 模板中,您可以執行以下操作:


@isset($isView)

<th class="disabled-sorting text-right" style="width:12%">Actions</th>

@endisset

// do the same @isset test for the corresponding <td> element

當您想要將其呈現為 Excel 時,您只需不傳遞此變量并且不會呈現該列。


查看完整回答
反對 回復 2023-08-11
  • 1 回答
  • 0 關注
  • 136 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號