cell formating for IMEI no.

Topics: Developer Forum, User Forum
Nov 7, 2011 at 12:58 PM
Edited Nov 7, 2011 at 12:58 PM

Hi all!

I using PHPExcel to export records from DB and everything works fine, everything except cell that contains IMEI (International Mobile Equipment Identity)

This is 15 digit number and all I get is 3.52006E+14 and I have to go to "Format cells > Number > Category and select Fraction or Custom[0]

in order to display this cell properly.

Im using this code to insert new cell - how can I format this cell?

$objPHPExcel->getActiveSheet(0)->setCellValue('A'.$i, $name);

 



Thanks in advance!

Nov 7, 2011 at 4:22 PM

You can set the format for numbers, etc. like this...

$format_imei = array(
	'numberformat' => array(
		'code' => '0',
	),
);
$objPHPExcel->getActiveSheet(0)->getStyle('A'.$i)->applyFromArray($format_imei);

Nov 9, 2011 at 8:43 AM

Thx Scott,

Works for me,

Have God Day!

Feb 1, 2012 at 1:55 PM

I have same problem at using getValue().

At the excel document 15 digit number is written but  after I use  getValue() i get  something like 3.52006E+14.

What can I do?

Coordinator
Feb 1, 2012 at 9:06 PM

Use setCellValueExplicit() with a datatype of PHPExcel_Cell_DataType::TYPE_STRING (that's the default) rather than setCellValue()