我正在尝试在excel表中制作工资单月度报告,以下是我在控制器中的功能。请参阅附件以及此问题。我的预期输出在同一附件中突出显示。
public function postPayrollMonthlyReport()
{
$departments_id = \Request::get('departments_id');
$month = \Request::get('month');
$data = EmployeePayroll::select('users.first_name as first_name','users.last_name as last_name','payroll_salary_deduction.deduction_label' , 'payroll_salary_deduction.deduction_value')
->join('users','users.id','=','payroll_manage_employee_payroll.user_id')
->join('payroll_salary_template','payroll_salary_template.salary_template_id','=','payroll_manage_employee_payroll.salary_template_id')
->join('payroll_salary_deduction','payroll_salary_deduction.salary_template_id','=','payroll_manage_employee_payroll.salary_template_id')
->where('users.departments_id',$departments_id)
->get();
return \Excel::create('monthly_payroll_report('.$month.')', function($excel) use ($data) {
$excel->sheet('mySheet', function($sheet) use ($data)
{
$sheet->fromArray($data);
});
})->download(xls);
}