'PHPExcel - Leading zero if number was shown in scientific notation

At work they use PHPExcel to generate Excel files with data of some products retrieved from a MySQL database. Some bar codes are 10+ characters long and Excel showed them in scientific notation. I fixed that, but now the cells that were expressed in scientific notation, Excel adds a leading zero and I can't remove it. I tried changing the cell data type to string many times, forcing the format to text and won't work. Also by adding spaces at the beggining and end of the code. I have to mention that if I double click the cell with number format it automatically removes the leading zero. Has anyone experienced something like this? If so, what did you do to fix this? I googled for a good amount of hours and I can't fix it.

Right now I can't move to PHPSpreadsheet because of time.

The piece of code in question:

$objPHPExcel->getActiveSheet()->setCellValueExplicit('D'.$i, " ". $f->code. " ", PHPExcel_Cell_DataType::TYPE_STRING);

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source