Ich habe vor kurzem heruntergeladen maatwebsite/Excel-Paket in Laravel für den Export der Datenbank Datensätze im Excel-Format.Eine zusätzliche Spalte und Zeile erscheint in der exportierten Excel-Datei mit Laravel maatwebsite/excel Paket
Die Installation war erfolgreich und ich kann die erwarteten Datenbankeinträge im Excel (.xls) -Format exportieren.
Ich habe aber feststellen, dass es eine zusätzliche Spalte und Zeile zu den erwarteten Daten eingefügt werden, wie unten gezeigt:
Hier row no. 8 und Spalte H sind unerwünscht. Im Anschluss an mein Controller-Code:
...
$audit_logs = $model->whereBetween('audit_log_created_date', [$_from, $_to])->get();
$file_name = 'Audit Log Report ('.$_from.' to '.$_to.')';
$type = AuditLog::$audit_log_type;
$action = AuditLog::$audit_log_action;
Excel::create($file_name, function($excel) use ($audit_logs,$type,$action) {
$excel->sheet('Sheet 1', function($sheet) use ($audit_logs,$type,$action) {
$sheet->loadView('/admin/audit-log/_export')->with([
'audit_logs' => $audit_logs,
'type' => $type,
'action' => $action
]);
});
})->export();
Und finden Sie meine Ansicht Code:
<style>
.trr {
background-color: #0099FF;
color: #ffffff;
align: center;
padding: 10px;
height: 20px;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html>
<table>
<thead>
<tr class="trr">
<td>S.no.</td>
<td>Type</td>
<td>Action</td>
<td>Event</td>
<td>Description</td>
<td>Username</td>
<td>Date & Time</td>
</tr>
</thead>
<tbody>
@if(!empty($audit_logs))
<?php $count = 0; ?>
@foreach($audit_logs as $audit_log)
<?php $count = $count+1; ?>
<tr style="border: 1px solid #040404; background-color: <?php if($count%2==0) echo '#E3F2FD'; else echo '#BBDEFB'; ?>;">
<td>{{ $count }}</td>
<td>{{ $type[$audit_log->audit_log_type] or null }}</td>
<td>{{ $action[$audit_log->audit_log_action] or null }}</td>
<td>{{ $audit_log->audit_log_event_id or null}}</td>
<td>{{ $audit_log->audit_log_description or null}}</td>
<td>{{ $audit_log->user->user_name or null}}</td>
<td>{{ $audit_log->audit_log_created_date or null}}</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</html>
Wenn jemand das Problem identifizieren kann, lass es mich wissen.
Vielen Dank für die Hilfe.