hemc4
hemc4

Reputation: 1633

php excel setting wrong cell value

when i set a cell value like this

->setCellValue('O' . $currentRow, 12000000000000111702)

or

->setCellValue('O' . $currentRow, "12000000000000111702")

it is generating values 1.2E+19 i.e 12000000000000000000 can anyone tell me the reason ?

Upvotes: 0

Views: 1227

Answers (1)

Mark Baker
Mark Baker

Reputation: 212522

If you need this value to be retained exactly "as is" rather than converted to a float (because it's too big for a PHP int), then you'll need to set the value explicitly as a string using

->setCellValueExplicit('O' . $currentRow, "12000000000000111702", PHPExcel_Cell_DataType::TYPE_STRING)

You don't actually need to specify PHPExcel_Cell_DataType::TYPE_STRING because setCellValueExplicit() defaults to that anyway.

Upvotes: 2

Related Questions