Commit e89b5371 by Phạm Văn Đoan

xuất excel

parent 2e93c476
......@@ -6,6 +6,7 @@ use App\Models\Track;
use App\Repositories\TrackRepository;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Maatwebsite\Excel\Facades\Excel;
class NctController extends Controller
{
......@@ -83,7 +84,26 @@ class NctController extends Controller
}
$response = null;
foreach ($tracks as $key => $track) {
Excel::create('weekly_report', function($excel) use ($tracks){
$excel->sheet('Sheetname', function($sheet) use ($tracks){
// Sheet manipulation
foreach ($tracks as $key => $val) {
$sheet->cell('A'.($key+1), function($cell) use ($val){
// manipulate the cell
$cell->setValue($val['title']);
});
}
/*$sheet->cells('A1:A5', function($cells) {
// manipulate the range of cells
});*/
});
})->store('xlsx', storage_path('exports/weekly_report'));
/*foreach ($tracks as $key => $track) {
$link = null;
$duration = 0;
$check = $this->privateGeTrackLink($tracks_playlist, $track['id_nct']);
......@@ -102,7 +122,7 @@ class NctController extends Controller
}
echo $track['title'] . "\t" . $track['id_nct'] . "\t" . $track['id_nct_str'] . "\t" . $track['singer'] . '<br>';
}
}*/
die();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment