i want to pass any variable to Excel:: like this
$data = array(
array('No', 'Name', 'Sex', 'Date of Birth', 'Salary'),
array('1', 'Theara', 'Male', '21-05-1982', 100),
array('2', 'Theara', 'Male', '21-05-1982', 100),
);
Excel::create('Filename', function($excel) {
$excel->sheet('Sheetname', function($sheet) {
$sheet->with($data);
});
})->export('xls');
Just like you would with PHP: use($data)
Excel::create('Filename', function($excel) use($data) {
});
Define instance/class variable in that class and assign $data to that variable before Excel::Create and use that class variable inside Excel::create . it works!
Most helpful comment
Just like you would with PHP:
use($data)