PhpSpreadsheet
PhpSpreadsheet copied to clipboard
zeros (0) gets removed
I have try this method to don't remove the zero (0)
public function columnFormats(): array {
return [
'A' => NumberFormat::FORMAT_NUMBER,
'B' => NumberFormat::FORMAT_TEXT,
'C' => NumberFormat::FORMAT_NUMBER,
];
}
I have also try this:
public function columnFormats(): array {
return [
'A' => NumberFormat::FORMAT_NUMBER,
'B' => '0',
'C' => NumberFormat::FORMAT_NUMBER,
];
}
I have also try this:
public function columnFormats(): array {
return [
'A' => NumberFormat::FORMAT_NUMBER,
'B' => '@',
'C' => NumberFormat::FORMAT_NUMBER,
];
}
I have also try this:
public function columnFormats(): array {
return [
'A' => NumberFormat::FORMAT_NUMBER,
'B' => NumberFormats::FORMAT_GENERAL,
'C' => NumberFormat::FORMAT_NUMBER,
];
}
I have also try to convert int to string in the view of my Laravel then also zero(0) get removed, I have use function to convert int to string:
- typecast
<table border="1">
<thead>
<tr>
<th>#</th>
<th>Single Open</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
{{ $i = 1 }}
@foreach($opensingle as $jod)
<tr>
<td>{{ $i ?? '' ?? '1' }}</td>
<td>{{ (string)$jod['open_digit'] }}</td>
<td>{{ $jod['total_amount'] }}</td>
{{ $i++ }}
</tr>
@endforeach
</tbody>
</table>
- String function strval() and settype():
<table border="1">
<thead>
<tr>
<th>#</th>
<th>Single Open</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
{{ $i = 1 }}
@foreach($opensingle as $jod)
<tr>
<td>{{ $i ?? '' ?? '1' }}</td>
<td>{{ strval($jod['open_digit']) }}</td> OR <td>{{ settype($jod['open_digit'], "string") }}</td> // answer of strval is empty and settype is 1
<td>{{ $jod['total_amount'] }}</td>
{{ $i++ }}
</tr>
@endforeach
</tbody>
</table>
If you're using Laravel, then perhaps it would be better if you asked about this on Laravel help
If you're using Laravel, then perhaps it would be better if you asked about this on Laravel help
ohk thank you
PR #2813 resolved an issue that seems similar to this one. If you can test against master, please see if that resolves your issue.
PR #2813 resolved an issue that seems similar to this one. If you can test against master, please see if that resolves your issue.
okay I will check out! but this issue is our side or SpartnerNL/Laravel-Excel
No update in over 4 months. Closing.