phpExcel write long number in cell

混江龙づ霸主 提交于 2019-12-29 04:23:24

问题


While writing the excel file is fine I see that really long numbers are formulas in excel

Example: 8.71129E+12

instead of: 1234567890

How can I change the format during the PHP Excel Creation?

I'm following the simple example here


回答1:


$objPHPExcel->getActiveSheet()->setCellValueExplicit('A1', '1234567890', PHPExcel_Cell_DataType::TYPE_STRING);



回答2:


Either set the value explicitly as a string, or set a number format mask for the cell that forces display of all digits (e.g. '#,##0' 0r '0') rather than default format.




回答3:


Try this code it's works for me :

$objPHPExcel
   ->getActiveSheet()
   ->getCellByColumnAndRow($col, $row)
   ->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);

And Good luck !



来源:https://stackoverflow.com/questions/5046157/phpexcel-write-long-number-in-cell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!