first batch of changes #182

This commit is contained in:
madflow 2017-03-30 10:45:52 +02:00
parent f1c58bdb59
commit 3c8796043b
3 changed files with 16 additions and 10 deletions

View File

@ -4,6 +4,11 @@ namespace Box\Spout\Writer\Common;
use Box\Spout\Writer\Common\Helper\CellHelper;
/**
* Class Cell
*
* @package Box\Spout\Writer\Common
*/
class Cell
{
/**
@ -18,13 +23,14 @@ class Cell
/**
* Formula cell type
* Not used at the moment
*/
const TYPE_FORMULA = 2;
/**
* Blank cell type
* Empty cell type
*/
const TYPE_BLANK = 3;
const TYPE_EMPTY = 3;
/**
* Boolean cell type
@ -38,20 +44,19 @@ class Cell
/**
* The value of this cell
* @var null | mixed
* @var mixed|null
*/
protected $value = null;
/**
* The cell type
* @var null
* @var int
*/
protected $type = null;
/**
* Cell constructor.
* @param $value mixed
* @param $comment string
*/
public function __construct($value)
{
@ -92,7 +97,7 @@ class Cell
if (CellHelper::isBoolean($value)) {
return self::TYPE_BOOLEAN;
} elseif (CellHelper::isEmpty($value)) {
return self::TYPE_BLANK;
return self::TYPE_EMPTY;
} elseif (CellHelper::isNumeric($this->getValue())) {
return self::TYPE_NUMERIC;
} elseif (CellHelper::isNonEmptyString($value)) {
@ -113,12 +118,13 @@ class Cell
/**
* @return bool
*/
public function isBlank()
public function isEmpty()
{
return $this->type === self::TYPE_BLANK;
return $this->type === self::TYPE_EMPTY;
}
/**
* Not used at the moment
* @return bool
*/
public function isFormula()

View File

@ -215,7 +215,7 @@ class Worksheet implements WorksheetInterface
$data .= ' office:value-type="float" calcext:value-type="float" office:value="' . $cell->getValue() . '">';
$data .= '<text:p>' . $cell->getValue() . '</text:p>';
$data .= '</table:table-cell>';
} else if ($cell->isBlank()) {
} else if ($cell->isEmpty()) {
$data .= '/>';
} else {
throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cell->getValue()));

View File

@ -226,7 +226,7 @@ EOD;
$cellXML .= ' t="b"><v>' . intval($cell->getValue()) . '</v></c>';
} else if ($cell->isNumeric()) {
$cellXML .= '><v>' . $cell->getValue() . '</v></c>';
} else if ($cell->isBlank()) {
} else if ($cell->isEmpty()) {
if ($this->styleHelper->shouldApplyStyleOnEmptyCell($styleId)) {
$cellXML .= '/>';
} else {