php - 单击导出 excel 按钮时如何传递链接参数?
问题描述
我需要帮助才能在 URL 上传递参数。
路由.php
Route::get('downloadExcel/{type}', 'ExcelController@downloadExcel');
刀片.php
<a href="{{ URL::to('/downloadExcel/xls') }}" class="btn btn-warning btn-sm hidden-print"><i class="glyphicon glyphicon-export"></i> Export to Excel</a>
控制器
class ExcelController extends Controller{
public function downloadExcel($type, Request $request)
{
return Excel::create('Laporan Kehadiran Harian', function($excel) use
($transaksi) {
$excel->sheet('mySheet', function($sheet) use ($transaksi)
{
$sheet->fromArray($transaksi);
});
})->download($type);
}
}
解决方案
在blade.php 中尝试将第二个参数设置为具有type
属性和要传递的值的数组。
如果它是“xls”,它将是以下内容:
<a href="{{ URL::to('/downloadExcel', array("type" => "xls")) }}"></a>
推荐阅读
- android - 顶级 build.gradle 文件中的 ext 属性
- c++ - C++11:没有复制构造函数的自定义基于范围的循环
- javascript - AVG(COLUMN_SCORE) 未写入 SQLite 数据库
- elasticsearch - 用于弹性搜索的 kubernetes 滚动更新
- networking - GKE Pod 连接到同一子网中的外部虚拟机
- azure - 添加了额外的即用即付订阅,许多 VM 大小不可用
- sql-server-2008 - 使用特殊字符进行字母数字排序的问题
- mysql - 根据两个表中设置的值,使用另一个表中的索引更新 MySQL 表
- c - 如何连接两个字符串并保存在C中的第三个变量中?
- mysql - 在 MySQL 中乘以一个范围