Home > Backend Development > PHP Tutorial > How to handle scientific notation when php exports to excel

How to handle scientific notation when php exports to excel

PHP中文网
Release: 2023-02-28 20:26:01
Original
5099 people have browsed it

This article introduces a method of scientific notation when exporting excel data using PHP for your reference.

How to implement scientific notation when php exports excel, the code is as follows:

getStyle($this->numToEn($col).($row+2))->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);  
$activeSheet->setCellValue($this->numToEn($col).($row+2)," ".$elements[$row][$col]);  //写入Excels单元格的内容之前加一个空格,防止长数字被转化成科学计数法  
$activeSheet->getStyle($this->numToEn($col).($row+2))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); 
?>
Copy after login

The above is the content of scientific notation when php exports excel. For more related content, please pay attention to the PHP Chinese website (www.php.cn )!

Related articles:

Two ways to export excel files natively with php

Details of the sample code for reading Excel time in PHPExcel

A code example for obtaining the content of an excel document through php

Related labels:
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template