I'm using LaravelExcel at my Laravel 5.8 project and it is working fine and perfect but the only problem is that, the data does not get inserted into proper columns.
Here is the result:
As you can see all the data are inserted into the column A However, it was supposed to insert data into separated columns like this image:
And here is my Export Class:
class StudentExportView implements FromView
{
public function view(): View
{
set_time_limit(0);
$student = new Student();
$students = $student->searchStudents()->get();
$custom = new Student();
$customs = $custom->all();
return view('admin.students.custom', compact('students','customs'));
}
}
And here is Controller method:
public function export_view()
{
return Excel::download(new StudentExportView, 'studentlist.csv');
}
So how to fix this issue so the csv file holds data in their proper column.
Also this is the View:
<table class="table table-sm table-bordered">
<thead>
<tr class="thead-dark">
<th>Row</th>
<th>Name</th>
<th>Family Name</th>
<th>National Code</th>
<th>Mobile Number</th>
<th>Province</th>
<th>City</th>
<th>Degree</th>
<th>Grade</th>
<th>Registered Time</th>
</tr>
</thead>
<tbody>
@if($students->count() != 0)
@foreach($students as $student)
<tr data-id="{{ $student->mbr_id }}"
data-mobile="{{ $student->mbr_mobile }}"
data-post-code="{{ $student->mbr_post_code }}"
data-address="{{ $student->mbr_address }}"
>
<td>{{ $student->mbr_name }}</td>
<td>
{{ $student->mbr_family }}
<a class="information text-danger float-left"><i class="fa fa-info-circle"></i></a>
</td>
<td>{{ $student->mbr_national_code }}</td>
<td>{{ $student->mbr_mobile }}</td>
<td>{{ $student->province }}</td>
<td>{{ $student->city }}</td>
<td>{{ $student->degree }}</td>
<td>{{ $student->grade }}</td>
<td>
@if($customs->find($student->mbr_id))
{{ jdate($customs->find($student->mbr_id)->created_at) }}
@endif
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="12" style="text-align: center">No data for showing
</td>
</tr>
@endif
</tbody>
</table>