Home > Article > Backend Development > How to handle scientific notation when php exports to excel
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 (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