Phpexce
A field with a value of 0 in the database, exported to Excel via Phpexcel, becomes blank, can you make it appear as 0? The Phpexcel version is 1.7.9 and the export format is Excel2003. The following code is found on the internet, but has not been tested successfully, but also please have the experience of the friend pointing twos.
Sets the number format for the contents of the cell. ///// If Phpexcel_writer_excel5 is used to generate the content,//It is important to note that the const variable in the Phpexcel_style_numberformat class defines the // In various custom formats, other types can be used normally, but when Setformatcode //Is format_number, the actual effect is not formatted as "0". Need //Modify the GETXF ($style) method in the source code of the Phpexcel_writer_excel5_format class, //In the IF ($this->_biff_version = = 0x0500) { (Near line No. 363) Add a //Line code: //if ($ifmt = = = ' 0 ') $ifmt = 1; //Set format to Phpexcel_style_numberformat::format_number, avoid some large numbers //are displayed using scientific notation, with the following setautosize method allows the contents//of each row to be displayed in its entirety as the original content. $objStyleA 5 ->getnumberformat ()
Format//Set cell number Formatsecho date (' H:i:s '). "Set cell number formats\n"; $objPHPExcel->getactivesheet ()->getstyle (' e4′)->getnumberformat () Setformatcode (phpexcel_style_numberformat::format_currency_eur_simple), $objPHPExcel->getactivesheet () Duplicatestyle ($objPHPExcel->getactivesheet ()->getstyle (' e4′), ' e5:e13′ ';
Reply to discussion (solution)
How come people have this kind of problem?
An estimate of 0 is null, so it doesn't show up, so you can change the idea to show him as a string
$number = 0;
Echo '. $number