numbers as text

Topics: User Forum
Jan 20, 2011 at 11:13 AM

High,

I am quit new in using phpExcel

but I did not find directly the answer to my question in the manuals

For GS1 I need to create an excel document (excel5)

There are some fields that only contains numbers but I want to convert them into characters  

ex 056 should also appear in the excel as 056 however when I open the excel after the program has run the value becomes 56 and this causes problems when I upload my file with GS1.

this is the line that I am using in my code

$objPHPExcel->getActiveSheet()->setCellValue('J'.$Row, '056');

 

 

Coordinator
Jan 20, 2011 at 11:23 AM
On 20/01/2011 12:13, tdmaris wrote:

There are some fields that only contains numbers but I want to convert them into characters

ex 056 should also appear in the excel as 056 however when I open the excel after the program has run the value becomes 56 and this causes problems when I upload my file with GS1.

this is the line that I am using in my code

$objPHPExcel->getActiveSheet()->setCellValue('J'.$Row, '056');


Either:
// Set the value explicitly as a string
$objPHPExcel->getActiveSheet()->setCellValueExplicit('J'.$Row, '056', PHPExcel_Cell_DataType::TYPE_STRING);

or

// Set the value as a number formatted with leading zeroes
$objPHPExcel->getActiveSheet()->setCellValue('J'.$Row, 56);
$objPHPExcel->getActiveSheet()->getStyle('J'.$Row)->getNumberFormat()->setFormatCode('000');


Jan 20, 2011 at 11:32 AM
Hello Mark
Thx it works