Cell Format

Topics: Developer Forum
Oct 28, 2010 at 1:38 AM

Hi,

 

Is there a chance to configure a cell to avoid auto-formatting?

Although I saved all cells' formatting settings to be "Text", not a formatted number, not a date or other... After .setCellValue some of the cells which do not have a string inside, but a high number, are converted into date or other malformed data.

Why does Excel or phpexcel overwrite my original cell formatting settings? How to prevent this behaviour through phpexcel?

 

Thanks!

Coordinator
Nov 1, 2010 at 11:01 PM

PHPExcel uses a Value Binder when data is written to a cell using the setValue() method. The default Value Binder can be found in Classes/PHPExcel/Cell/DefaultValueBinder.php and the dataTypeForValue() attempts to identify an appropriate datatype.

If you want to change this behaviour, then either use setValueExplicit() rather than setValue(); or write your own Value Binder to override the Default Value Binder. You can then use

PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_MyPersonalValueBinder() );

to enable your binder rules.