0

I read in this tutorial : https://laravel-excel.maatwebsite.nl/3.0/exports/column-formatting.html

My script export like this :

namespace App\Exports;
...
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
class SummaryExport implements WithColumnFormatting
{
    ...
    public function columnFormats(): array
    {
        return [
            'H' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2
    }
}

For example the real value = 30132,7531

If I use the format in my script above, it will to be : 30.132,75

It doesn't match the format I want

I want the format like this : 30.133

I try custom the format in the PhpOffice\PhpSpreadsheet\Style\NumberFormat;

I add this :

const FORMAT_NUMBER_CUSTOM = '#,##0';

And I add the const to my script above, it works, the result 30.133

I want to ask whether this is the right way? And can I edit the number format inside the vendor folder?

This PhpOffice\PhpSpreadsheet\Style\NumberFormat; located in vendor folder

moses toh
  • 12,344
  • 71
  • 243
  • 443
  • 1
    Don’t overwrite the vendor file. create a class and then extend this class and then overwrite property and method in your class – rkj Aug 07 '18 at 04:15
  • @rkj I had do it and it works. Thanks a lot – moses toh Aug 07 '18 at 04:27
  • 2
    I think you should define `FORMAT_NUMBER_COMMA_SEPARATED2` constant within your `SummaryExport` export class. – Mahbub Aug 07 '18 at 07:10

1 Answers1

0

refer to: laravel maatwebsite excel export currency row

you can also use data format in your table:

<td data-format="0.00">Price</td>
Alver
  • 3
  • 2