PHPExcel icon indicating copy to clipboard operation
PHPExcel copied to clipboard

Cell formatting with PHPExcel_Cell_DataType::TYPE_STRING does not work

Open Oluwafemikorede opened this issue 9 years ago • 4 comments

Hello,

Formatting of cells with PHPExcel_Cell_DataType::TYPE_STRING does not work for me, I am trying to collect phone number from the excel generated but its always stripping the first 0 from the excel.

I am using PHPExcel version 1.8.0.

Oluwafemikorede avatar Jun 28 '16 14:06 Oluwafemikorede

How are you setting the cell value? Simply setting formatting to a type of string won't automagically convert a numeric value to one with leading zeroes, you need to set the cell value explicitly as a string datatype to retain the existing leading zeroes

MarkBaker avatar Jun 28 '16 18:06 MarkBaker

This is my code

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

Oluwafemikorede avatar Jun 28 '16 22:06 Oluwafemikorede

So you're setting an empty string?

Alright, what format are you writing, and how are you checking how it's been written?

MarkBaker avatar Jun 29 '16 07:06 MarkBaker

i also tried the same thing, but does not work either

hashvg7 avatar Jan 27 '18 08:01 hashvg7