solve Phpexcel long digital string display for scientific counting
https://github.com/PHPOffice/PHPExcel/
In Excel, if you enter or copy an extra-long numeric string in a default grid, it appears as a scientific calculation, such as a social security number, and the workaround is to format the table text or add a single quotation mark before the input. Using Phpexcel to generate Excel, you will also encounter the same problem, there are three ways to solve it:1, set cell to text $objphpexcel=NewPhpexcel (); $objPHPExcel->setactivesheetindex (0); $objPHPExcel->getactivesheet ()->settitle (' Simple');//set A3 cell to text$objPHPExcel->getactivesheet ()->getstyle ('A3'),Getnumberformat ()-Setformatcode (phpexcel_style_numberformat::format_text);//You can also set a style for an entire row or column/*//e is listed as Text $objphpexcel->getactivesheet ()->getstyle (' E ')->getnumberformat ()->setformatcode ( Phpexcel_style_numberformat::format_text);//third act Text $objphpexcel->getactivesheet ()->getstyle (' 3 ') Getnumberformat ()->setformatcode (phpexcel_style_numberformat::format_text);*/more formats can be found in the Phpexcel/style/found in numberformat.php. Note: The above setting shows the result of scientific notation for long numeric strings or text, because of the scientific notation that PHP uses when dealing with large numbers. 2, the specified data type is displayed when the value is set $objphpexcel=NewPhpexcel (); $objPHPExcel->setactivesheetindex (0); $objPHPExcel->getactivesheet ()->settitle (' Simple'); $objPHPExcel->getactivesheet ()->setcellvalueexplicit ('D1', 123456789033, phpexcel_cell_datatype::type_string);3, add a space before the numeric string to make it a string $objphpexcel=NewPhpexcel (); $objPHPExcel->setactivesheetindex (0); $objPHPExcel->getactivesheet ()->settitle (' Simple'); $objPHPExcel->getactivesheet ()->setcellvalue ('D1',' '.123456789033);
Recommended to use the second to third type, the first one does not solve the problem at all.
Solve Phpexcel long digital string display for scientific counting