When exported to excel in php, the number of words becomes scientific count.

Source: Internet
Author: User
When exporting data to excel in php, the numeric format becomes scientific count. when exporting data to excel, the numeric format is incorrect. Generally, the following two cases are involved: 1. the length of the excel cell is not enough. The solution is as follows: // in excel. in the php file, $ objActSheet = $ objPHPExcel-& gt; ge converts the number to scientific count when it is exported to excel in php.

When exporting data to excel, the numeric format is incorrect. the following two situations are generally used:


1. the length of an excel cell is not enough. The solution is as follows:

// In excel. $ objActSheet = $ objPHPExcel-> getActiveSheet (); // set the topic name $ objActSheet-> setCellValue ("b1", "Card number "); // Set the column width $ objActSheet-> getColumnDimension ('B')-> setWidth (20); // change the length value set here


2. when the character is understood as a number in excel, it is generally set to text or try to add spaces. my solution is as follows:

// Add data, mainly to process the data to be displayed using the chunk_split () function. for specific usage of this function, you can view $ objActSheet-> setCellValue ("B $ I ", chunk_split ("123456789", 4, ""); // of course, if you do not want to see spaces between numbers, set the value of the field to be split to a greater value, for example, set 4 to a value greater than or equal to 9.

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.