douxi3233 2013-01-15 12:47
浏览 6
已采纳

php excel设置错误的单元格值

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 ?

  • 写回答

1条回答 默认 最新

  • doudou8783 2013-01-15 13:03
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?