PHPExcel - set cell type before writing a value in it

Psyche picture Psyche · Jun 17, 2013 · Viewed 99.9k times · Source

Do you know how can I set the cell type before writing a value in it? I would like to be able to set types like "General", "Text" and "Number".

Thank you.

Answer

FelipeR picture FelipeR · Sep 24, 2015

When the text is a number with leading zeros, then do: (Cuando el texto es un número que empieza por ceros, hacer)

$objPHPExcel->getActiveSheet()->setCellValueExplicit('A1', $val,PHPExcel_Cell_DataType::TYPE_STRING);