Home > Backend Development > PHP Tutorial > How to solve the problem of converting numbers into scientific notation when exporting data to excel

How to solve the problem of converting numbers into scientific notation when exporting data to excel

WBOY
Release: 2016-07-25 09:05:44
Original
1677 people have browsed it
  1. //In the excel.php file
  2. $objActSheet = $objPHPExcel->getActiveSheet();
  3. //Set the column name
  4. $objActSheet->setCellValue("b1", "Card Number");
  5. //Set the width of the column
  6. $objActSheet->getColumnDimension('b')->setWidth(20);//Change the length value set here
Copy code

2. The characters are excel If you understand it as a number, you usually set the field to text or find a way to add some spaces. Solution:

  1. //Add data, mainly process the data to be displayed with the chunk_split() function. You can check the specific usage of this function by yourself
  2. $objActSheet->setCellValue ( "b$i", chunk_split( "123456789 ",4," ") );//Of course, if you don't want users to see spaces between numbers, then set the field value to be divided larger. For example, set 4 in the example to greater than or equal to 9. Can.
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template