mardi 24 septembre 2019

Phpspreadsheet rounding off the accountnumbers and removing 0 from starting

I am working on phpspreadsheet where i am downloading the users account details, but phpspreadsheet is rounding off the account numbers and also removing the 0 from starting.

Example:

Original=> 545778985645453699 After PHPSpreadsheet code => 545778985645453700

Original=> 0256884555 After PHPSpreadsheet code => 256884555

I want numbers to be exact like i am pulling from DB using laravel.

Tried, converting datatype but its making cells value to 0. Tried numberformat its also not working.

$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
        $sheet = $spreadsheet->getSheet(0);
        $sheet->fromArray($Final, null, 'A1');
        $sheet->getStyle('A1:A1')
            ->getNumberFormat()
            ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
        $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);

Is there any alternate colution for this issue, or am i doing anything wrong here.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire