Skip to content

Commit 69e67d9

Browse files
committed
Changed normalizeColumn to 1-based column index
1 parent d4c7d53 commit 69e67d9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ExcelSheet.php

Lines changed: 4 additions & 4 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) + 1; // Add 1 because PhpSpreadsheet is 1-based
232+
$col = array_shift($keys);
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) + 1; // Add 1 because PhpSpreadsheet is 1-based
268+
$col = $i + self::normalizeColumn($this->startColumn);
269269
if (isset($formatters[$col]) && is_callable($formatters[$col])) {
270270
$value = call_user_func($formatters[$col], $value, $row, $data);
271271
}
@@ -307,12 +307,12 @@ protected function normalizeIndex($data)
307307
/**
308308
* @param int|string $column the column either as int or as string. If
309309
* numeric, the startColumn offset will be added.
310-
* @return int the normalized numeric column index (0-based).
310+
* @return int the normalized numeric column index (1-based).
311311
*/
312312
public function normalizeColumn($column)
313313
{
314314
if (is_string($column)) {
315-
return \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($column) - 1;
315+
return \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($column);
316316
} else {
317317
return $column + self::normalizeColumn($this->startColumn);
318318
}

0 commit comments

Comments
 (0)