Number as String?

Topics: Developer Forum, User Forum
Jun 8, 2010 at 3:28 PM
Edited Jun 8, 2010 at 3:38 PM
Hello, i want to create a cell with the String "0029" in it. But if i create the excel-sheet, the string is converted to the number "29", but i want ist to be "0029". i have set the data type to String with: "$objPHPExcel->getActiveSheet()->getCell("A1")->setValueExplicit(PHPExcel_Cell_DataType::TYPE_STRING);" but this doesnt help... can someone help me with this? thank you
Coordinator
Jun 8, 2010 at 4:17 PM
Edited Jun 8, 2010 at 4:17 PM
// Set the value explicitly as a string
$objPHPExcel->getActiveSheet()->setCellValueExplicit('A1', '0029', PHPExcel_Cell_DataType::TYPE_STRING);
or
// Set the value as a number formatted with leading zeroes
$objPHPExcel->getActiveSheet()->setCellValue('A3', 29);
$objPHPExcel->getActiveSheet()->getStyle('A3')->getNumberFormat()->setFormatCode('0000');