Feature: Advanced Value Binder now recognises TRUE/FALSE strings (locale-specific) and converts to boolean

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@61103 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2010-09-17 22:41:31 +00:00
parent a3a0aa73e7
commit 31196f0a14
3 changed files with 31 additions and 1 deletions

View File

@ -192,7 +192,7 @@ class PHPExcel_Calculation {
);
private static $_localeArgumentSeparator = ',';
private static $_localeFunctions = array();
private static $_localeBoolean = array( 'TRUE' => 'TRUE',
public static $_localeBoolean = array( 'TRUE' => 'TRUE',
'FALSE' => 'FALSE',
'NULL' => 'NULL'
);
@ -1686,6 +1686,26 @@ class PHPExcel_Calculation {
} // function __clone()
/**
* Return the locale-specific translation of TRUE
*
* @access public
* @return string locale-specific translation of TRUE
*/
public static function getTRUE() {
return self::$_localeBoolean['TRUE'];
}
/**
* Return the locale-specific translation of FALSE
*
* @access public
* @return string locale-specific translation of FALSE
*/
public static function getFALSE() {
return self::$_localeBoolean['FALSE'];
}
/**
* Set the Array Return Type (Array or Value of first element in the array)
*

View File

@ -54,6 +54,15 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Style logic - strings
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
// Test for booleans using locale-setting
if ($value == PHPExcel_Calculation::getTRUE()) {
$cell->setValueExplicit( True, PHPExcel_Cell_DataType::TYPE_BOOL);
return true;
} elseif($value == PHPExcel_Calculation::getFALSE()) {
$cell->setValueExplicit( False, PHPExcel_Cell_DataType::TYPE_BOOL);
return true;
}
// Check for number in scientific format
if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) {
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);

View File

@ -30,6 +30,7 @@ Fixed in SVN:
- Feature: (MBaker) Support for Extended Workbook Properties in Excel2007, Excel5 and OOCalc Readers; support for User-defined Workbook Properties in Excel2007 and OOCalc Readers
- Feature: (MBaker) Support for Extended and User-defined Workbook Properties in Excel2007 Writer
- Feature: (MBaker) Provided a setGenerateSheetNavigationBlock(false); option to suppress generation of the sheet navigation block when writing multiple worksheets to HTML
- Feature: (MBaker) Advanced Value Binder now recognises TRUE/FALSE strings (locale-specific) and converts to boolean
- Bugfix: (Progi1984) Workitem 7895 - Excel5 : Formula : Percent
- Bugfix: (MB) Work item 14143 - NA() doesn't propagate in matrix calc - quick fix in JAMA/Matrix.php
- Bugfix: (Progi1984) Workitem 7895 - Excel5 : Formula : Error constant