Skip to content

Commit d4c7d53

Browse files
committed
Fixed col-numbering on setCellValue to 1-based.
1 parent 8c9c5da commit d4c7d53

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ExcelSheet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ protected function renderTitle()
229229
$titles = $this->normalizeIndex($this->getTitles());
230230
if ($titles) {
231231
$keys = array_keys($titles);
232-
$col = array_shift($keys);
232+
$col = array_shift($keys) + 1; // Add 1 because PhpSpreadsheet is 1-based
233233
foreach ($titles as $title) {
234234
$this->_sheet->setCellValueByColumnAndRow($col++, $this->_row, $title);
235235
}
@@ -265,7 +265,7 @@ protected function renderRows()
265265
protected function renderRow($data, $row, $formats, $formatters, $callbacks, $types)
266266
{
267267
foreach (array_values($data) as $i => $value) {
268-
$col = $i + self::normalizeColumn($this->startColumn);
268+
$col = $i + self::normalizeColumn($this->startColumn) + 1; // Add 1 because PhpSpreadsheet is 1-based
269269
if (isset($formatters[$col]) && is_callable($formatters[$col])) {
270270
$value = call_user_func($formatters[$col], $value, $row, $data);
271271
}

0 commit comments

Comments
 (0)