Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Build and return xml for a single cell.
- *
- * @param int $rowIndex
- * @param int $cellNumber
- * @param mixed $cellValue
- * @param int $styleId
- * @return string
- * @throws InvalidArgumentException If the given value cannot be processed
- */
- protected function getCellXML($rowIndex, $cellNumber, $cellValue, $styleId)
- {
- $columnIndex = CellHelper::getCellIndexFromColumnIndex($cellNumber);
- $cellXML = '<c r="' . $columnIndex . $rowIndex . '"';
- $cellXML .= ' s="' . $styleId . '"';
- if (CellHelper::isNonEmptyString($cellValue)) {/* return (gettype($value) === 'string' && $value !== '');*/
- $cellXML .= $this->getCellXMLFragmentForNonEmptyString($cellValue);
- } else if (CellHelper::isBoolean($cellValue)) {
- $cellXML .= ' t="b"><v>' . intval($cellValue) . '</v></c>';
- } else if (CellHelper::isNumeric($cellValue)) {
- $cellXML .= '><v>' . $cellValue . '</v></c>';
- } else if (empty($cellValue)) {
- if ($this->styleHelper->shouldApplyStyleOnEmptyCell($styleId)) {
- $cellXML .= '/>';
- } else {
- // don't write empty cells that do no need styling
- // NOTE: not appending to $cellXML is the right behavior!!
- $cellXML = '';
- }
- } else {
- throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cellValue));
- }
- return $cellXML;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement