diff --git a/src/Spout/Writer/XLSX/Internal/Worksheet.php b/src/Spout/Writer/XLSX/Internal/Worksheet.php index be67e19..c6f77e6 100644 --- a/src/Spout/Writer/XLSX/Internal/Worksheet.php +++ b/src/Spout/Writer/XLSX/Internal/Worksheet.php @@ -133,28 +133,26 @@ EOD; $data = ''; - foreach($dataRow as $cellValue) { - $columnIndex = CellHelper::getCellIndexFromColumnIndex($cellNumber); - $data .= 'getId() . '"'; - - if (CellHelper::isNonEmptyString($cellValue)) { - if ($this->shouldUseInlineStrings) { - $data .= ' t="inlineStr">' . $this->stringsEscaper->escape($cellValue) . ''; + foreach ($dataRow as $cellValue) { + if (!empty($cellValue)) { + $columnIndex = CellHelper::getCellIndexFromColumnIndex($cellNumber); + $data .= 'getId() . '"'; + if (CellHelper::isNonEmptyString($cellValue)) { + if ($this->shouldUseInlineStrings) { + $data .= ' t="inlineStr">' . $this->stringsEscaper->escape($cellValue) . ''; + } else { + $sharedStringId = $this->sharedStringsHelper->writeString($cellValue); + $data .= ' t="s">' . $sharedStringId . ''; + } + } else if (CellHelper::isBoolean($cellValue)) { + $data .= ' t="b">' . $cellValue . ''; + } else if (CellHelper::isNumeric($cellValue)) { + $data .= '>' . $cellValue . ''; } else { - $sharedStringId = $this->sharedStringsHelper->writeString($cellValue); - $data .= ' t="s">' . $sharedStringId . ''; + throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cellValue)); } - } else if (CellHelper::isBoolean($cellValue)) { - $data .= ' t="b">' . $cellValue . ''; - } else if (CellHelper::isNumeric($cellValue)) { - $data .= '>' . $cellValue . ''; - } else if (empty($cellValue)) { - $data .= '/>'; - } else { - throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cellValue)); } - $cellNumber++; }