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

How to handle scientific notation when php exports to excel

PHP中文网
PHP中文网Original
2017-03-25 11:53:314968browse

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); 
?>

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

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

Statement:
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