Search code examples
phplaravelphpexcelmaatwebsite-excel

laravel excel export - data storing as text instead of number


I'm trying to export an excel with all the data pushed in it. After downloading the excel, the integer cells are stored as text with a small green triangle with an error

The number in this cell is formatted as text or preceded by an apostrophe

I also tried using setColumnFormat function to convert all the columns to int datatype, but didn't work

$sheet->setColumnFormat(array('A:AP' => \PHPExcel_Style_NumberFormat::FORMAT::NUMBER));

Also while pushing the data in the cell, I'm using number_format function which didn't work either.

Looking for help!


Solution

  • I think it should be resolved once you remove number_format() This function returns string type instead of number. Please check PHP Manual and this quick example