Merge 8ac86cb254228d9faaa9d23e9936e840ef7d4dc3 into 4ff9717b0adc71ccf84c6e93b38e4188c77f39b4

This commit is contained in:
Stephen Sweetland 2019-05-24 01:52:20 +00:00 committed by GitHub
commit e125f1b677
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -64,6 +64,17 @@ class CellHelper
return (gettype($value) === 'string' && $value !== ''); return (gettype($value) === 'string' && $value !== '');
} }
/**
* Returns whether the given value looks like a formula
*
* @param $value
* @return bool whether the given value looks like a formula
*/
public static function isFormulaString($value)
{
return (strpos($value,'=') === 0);
}
/** /**
* Returns whether the given value is numeric. * Returns whether the given value is numeric.
* A numeric value is from type "integer" or "double" ("float" is not returned by gettype). * A numeric value is from type "integer" or "double" ("float" is not returned by gettype).

View File

@ -212,8 +212,10 @@ EOD;
$columnIndex = CellHelper::getCellIndexFromColumnIndex($cellNumber); $columnIndex = CellHelper::getCellIndexFromColumnIndex($cellNumber);
$cellXML = '<c r="' . $columnIndex . $rowIndex . '"'; $cellXML = '<c r="' . $columnIndex . $rowIndex . '"';
$cellXML .= ' s="' . $styleId . '"'; $cellXML .= ' s="' . $styleId . '"';
if (CellHelper::isNonEmptyString($cellValue)) { if (CellHelper::isFormulaString($cellValue)) {
$cellXML .= '><f>'.substr($cellValue,1).'</f><v>0</v></c>'; // seriously, that's it.
} else if (CellHelper::isNonEmptyString($cellValue)) {
$cellXML .= $this->getCellXMLFragmentForNonEmptyString($cellValue); $cellXML .= $this->getCellXMLFragmentForNonEmptyString($cellValue);
} else if (CellHelper::isBoolean($cellValue)) { } else if (CellHelper::isBoolean($cellValue)) {
$cellXML .= ' t="b"><v>' . intval($cellValue) . '</v></c>'; $cellXML .= ' t="b"><v>' . intval($cellValue) . '</v></c>';