Unless you use
By default, this is
There is also an advanced
If you pass a string value like
To enable the advanced value binder, call
You can find an example of advanced binder usage in
setCellValueExplicit()
, then PHPExcel uses a value binder
to identify the datatype that you are setting in the cell. By default, this is
PHPExcel_Cell_DefaultValueBinder
, which performs a very simplistic check on whether the PHP datatype is Null or Boolean, or a numeric value or a string. A value such as 37.7%
is a PHP string, so will be treated as a string.There is also an advanced
value binder
(PHPExcel_Cell_AdvancedValueBinder
) that can perform much more sophisticated checks, and is capable of identifying strings containing basic date formats and converting them to an Excel serialized datetime, and setting a number format mask accordingly. It can also detect currency values, fractions, and (most importantly) percentages.If you pass a string value like
37.7%
through the advanced value binder, it will divide the numeric part by 100, and set the number format mask to a percentage mask, in exactly the same way as the MS Excel GUI.To enable the advanced value binder, call
PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() );
before instantiating your PHPExcel object.You can find an example of advanced binder usage in
/Examples/29advancedvaluebinder.php