Solve Phpexcel long digital string display for scientific counting

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.