Answers for "laravel excel avoid scientific notation for long numbers"

PHP
0

laravel excel avoid scientific notation for long numbers

// in database		: 1277192403076020
// in exported excel: 1,27719E+15

// how do i prevent that?
// here example:

<?php

namespace App\Exports\Pages;

use App\Models\YourModel;
use Maatwebsite\Excel\Concerns\FromCollection;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;

class PicsExport implements FromCollection, WithColumnFormatting
{
  	public function collection(){
    	// ...
    }
  
	public function columnFormats(): array{
        return [
            'A' => NumberFormat::FORMAT_NUMBER, // add this
        ];
	}
  
}
Posted by: Guest on October-05-2021

Code answers related to "laravel excel avoid scientific notation for long numbers"

Browse Popular Code Answers by Language