Merge ac2342b260 into 8459666841
This commit is contained in:
3 files changed
+30
-3
No files matched your search
@@ -139,6 +139,9 @@ class Cell
|
|||||||
*/
|
*/
|
||||||
protected function detectType($value)
|
protected function detectType($value)
|
||||||
{
|
{
|
||||||
|
if (CellTypeHelper::isFormula($value)) {
|
||||||
|
return self::TYPE_FORMULA;
|
||||||
|
}
|
||||||
if (CellTypeHelper::isBoolean($value)) {
|
if (CellTypeHelper::isBoolean($value)) {
|
||||||
return self::TYPE_BOOLEAN;
|
return self::TYPE_BOOLEAN;
|
||||||
}
|
}
|
||||||
@@ -198,6 +201,14 @@ class Cell
|
|||||||
return $this->type === self::TYPE_DATE;
|
return $this->type === self::TYPE_DATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isFormula()
|
||||||
|
{
|
||||||
|
return $this->type === self::TYPE_FORMULA;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -60,9 +60,19 @@ class CellTypeHelper
|
|||||||
*/
|
*/
|
||||||
public static function isDateTimeOrDateInterval($value)
|
public static function isDateTimeOrDateInterval($value)
|
||||||
{
|
{
|
||||||
return (
|
return ($value instanceof \DateTimeInterface ||
|
||||||
$value instanceof \DateTimeInterface ||
|
|
||||||
$value instanceof \DateInterval
|
$value instanceof \DateInterval
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given value looks like a formula
|
||||||
|
*
|
||||||
|
* @param $value
|
||||||
|
* @return bool whether the given value looks like a formula
|
||||||
|
*/
|
||||||
|
public static function isFormula($value)
|
||||||
|
{
|
||||||
|
return (is_array($value) || strpos($value, '=') === 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -228,7 +228,13 @@ EOD;
|
|||||||
$cellXML = '<c r="' . $columnLetters . $rowIndexOneBased . '"';
|
$cellXML = '<c r="' . $columnLetters . $rowIndexOneBased . '"';
|
||||||
$cellXML .= ' s="' . $styleId . '"';
|
$cellXML .= ' s="' . $styleId . '"';
|
||||||
|
|
||||||
if ($cell->isString()) {
|
if ($cell->isFormula()) {
|
||||||
|
if (is_array($cell->getValue())) {
|
||||||
|
$cellXML .= ' ><f>' . substr($cell->getValue()[0], 1) . '</f><v>' . $cell->getValue()[1] . '</v></c>';
|
||||||
|
} else {
|
||||||
|
$cellXML .= ' ><f>' . substr($cell->getValue(), 1) . '</f></c>';
|
||||||
|
}
|
||||||
|
} elseif ($cell->isString()) {
|
||||||
$cellXML .= $this->getCellXMLFragmentForNonEmptyString($cell->getValue());
|
$cellXML .= $this->getCellXMLFragmentForNonEmptyString($cell->getValue());
|
||||||
} elseif ($cell->isBoolean()) {
|
} elseif ($cell->isBoolean()) {
|
||||||
$cellXML .= ' t="b"><v>' . (int) ($cell->getValue()) . '</v></c>';
|
$cellXML .= ' t="b"><v>' . (int) ($cell->getValue()) . '</v></c>';
|
||||||
|
|||||||
Reference in new issue
Block a user