Home > OS >  How to display the original data in excel whichever returns from the database in php?
How to display the original data in excel whichever returns from the database in php?

Time:12-29

I am using matwebsite for exporting excel files ,i am getting the data from the database it's stored in the exported excel file upto this part it's working fine .some of the values are more than 15 digits at that time it's displaying as scientifc format for that i made some changes using columnFormats() function now it supports upto 16 digits ,if any value more than 16 digits it's replacing last digits as zero's ,How to rectify this error please help me to fix this issue..

``

public function columnFormats(): array
{
    return [
        'D' => '#0',
    ];
}

**my downloaded excel**


1234567890123456  //16 digits it's working fine

12345678901234567000 //actual value is 1234567890123456789

CodePudding user response:

Columnformats function tells the excel to convert to a numeric behaviour in Excel the numeric supports upto 16 digits so this change is not working in your case.

If you want to acheive your scenario use this following reference bindValue() function and change the data type as string(string in Excel supports more characters).

https://docs.laravel-excel.com/3.1/imports/custom-formatting-values.html

  • Related