How can I export a file in Excel that shows the leading zeros using the PHPexcel library?

0

Good morning, I have some data in MySql which I export to Excel using the PHPExcel library, but some of the codes contain "zero" on the left, example: 010, but at the time of generating the Excel the data remains as "10" and I need it to be as it originally is, that is "010" I have already formatted the cells using this sentence:

$objPHPExcel = new PHPExcel();
$objPHPExcel->getDefaultStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);

Although it actually leaves me the file with all the cells in text format, it continues to remove the zero on the left, I have already tried some codes found in some forums without getting the result I need, I appreciate any help. I've also tried this:

$objPHPExcel->getActiveSheet()->setSharedStyle($estiloInformacion, "A4:J".($i-1),PHPExcel_Cell_DataType::TYPE_STRING);

    
asked by Diego Farid Grijalba Andrade 11.09.2018 в 18:09
source

1 answer

0

Hello try to enter a value forcibly, without the variable: $ styleInformation, just to check that it is not PHPExcel_Cell_DataType problem, maybe the value comes from the databases without the 0 or when passing it in php as variable ..

    
answered by 13.09.2018 в 23:24