When I try to export datas as excel file on the specific request I got below error
PhpOffice\PhpSpreadsheet\Reader\Exception Failed to load path_to_project\storage\framework\laravel-excel\laravel-excel-pz23rYwVENIOZUw7vnvhKaNjUkkNLNT8.html as a DOM Document
I search alot but couldnot find any answer, the problem comes only when semester = First Sem
but when semester is second, third etc this error doesn't come and I can download excel.
Below are my code
Route::get('/export', function () {
return Excel::download(new ReportExport(request()->exams, request()->course, request()->semesterName), ''.request()->course.' '.request()->semesterName.'('.request()->exams.').xlsx');
})
// ReportExcel.php
$data = Fee::with(['backpapers' => function($bp) use ($myCourse, $semName) {
$bp->where('course_name', $myCourse)->where('semester', $semName);
}])->get();
$table = '<table class="table table-border table-hover"><thead><tr><th>#</th><th>Roll No</th><th>Name</th><th>Reg_No</th><th>Father\'s Name</th><th>Gender</th><th>Aadhaar No</th><th>Mobile</th><th>Email</th><th>Paper 1</th><th>Paper 2</th><th>Paper 3</th><th>Paper 4</th><th>Exam Fee</th></tr></thead><tbody>';
$count = 1;
foreach ($data as $key => $bp) {
if (count($bp->backpapers) > 0) {
$table .= '<tr><td>'.$count.'</td><td>'.$bp->roll_number.'</td><td>'.$bp->name.'</td><td>'.($bp->registration_number != null ? $bp->registration_number : '-').'</td><td>'.$bp->father_name.'</td><td>'.($bp->gender == 1 ? 'Male' : 'Female').'</td><td>'.($bp->aadhaar_number != null ? $bp->aadhaar_number : '-').'</td><td>'.$bp->mobile_number.'</td><td>'.($bp->email != null ? $bp->email : '-').'</td>';
$paperFee = BackpaperFee::where('number_of_paper', count($bp->backpapers))->pluck('fee_amount')->first();
if (count($bp->backpapers) == 4) {
foreach ($bp->backpapers as $bpp) {
$table .= '<td>'.$bpp->paper_name.'</td>';
}
} elseif (count($bp->backpapers) == 3) {
foreach ($bp->backpapers as $bpp) {
$table .= '<td>'.$bpp->paper_name.'</td>';
}
$table .= '<td>-</td>';
} elseif (count($bp->backpapers) == 2) {
foreach ($bp->backpapers as $bpp) {
$table .= '<td>'.$bpp->paper_name.'</td>';
}
$table .= '<td>-</td><td>-</td>';
} elseif (count($bp->backpapers) == 1) {
foreach ($bp->backpapers as $bpp) {
$table .= '<td>'.$bpp->paper_name.'</td>';
}
$table .= '<td>-</td><td>-</td><td>-</td>';
}
$table .= '<td>'.$paperFee.'</td></tr>';
$count++;
}
}
$table .= '</tbody></table>';
return view('excel', compact('table'));
Like I said earlier, the error occurs when semester=First Sem
only.
I tried:
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan config:clear
But nothing works.. Thanks in advance