Box\Spout\Writer\ODS\Internal\Worksheet::getCellXML PHP Method

getCellXML() protected method

Returns the cell XML content, given its value.
protected getCellXML ( mixed $cellValue, integer $styleIndex, integer $numTimesValueRepeated ) : string
$cellValue mixed The value to be written
$styleIndex integer Index of the used style
$numTimesValueRepeated integer Number of times the value is consecutively repeated
return string The cell XML content
    protected function getCellXML($cellValue, $styleIndex, $numTimesValueRepeated)
    {
        $data = '<table:table-cell table:style-name="ce' . $styleIndex . '"';
        if ($numTimesValueRepeated !== 1) {
            $data .= ' table:number-columns-repeated="' . $numTimesValueRepeated . '"';
        }
        if (CellHelper::isNonEmptyString($cellValue)) {
            $data .= ' office:value-type="string" calcext:value-type="string">';
            $cellValueLines = explode("\n", $cellValue);
            foreach ($cellValueLines as $cellValueLine) {
                $data .= '<text:p>' . $this->stringsEscaper->escape($cellValueLine) . '</text:p>';
            }
            $data .= '</table:table-cell>';
        } else {
            if (CellHelper::isBoolean($cellValue)) {
                $data .= ' office:value-type="boolean" calcext:value-type="boolean" office:boolean-value="' . $cellValue . '">';
                $data .= '<text:p>' . $cellValue . '</text:p>';
                $data .= '</table:table-cell>';
            } else {
                if (CellHelper::isNumeric($cellValue)) {
                    $data .= ' office:value-type="float" calcext:value-type="float" office:value="' . $cellValue . '">';
                    $data .= '<text:p>' . $cellValue . '</text:p>';
                    $data .= '</table:table-cell>';
                } else {
                    if (empty($cellValue)) {
                        $data .= '/>';
                    } else {
                        throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cellValue));
                    }
                }
            }
        }
        return $data;
    }