PHPSpreadsheet cell value duplicate for multiline value

71 views Asked by At

I have a multi-line cell value that I am trying to insert into an Excel sheet. While using multiline value, the cell values are duplicated every 16 rows.

For Example

<?php
require __DIR__ . '/vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\IOFactory;

$spreadSheetObject = new Spreadsheet();

$range = range(1, 34);
foreach ($range as $row) {
    $spreadSheetObject->getActiveSheet()->setCellValue("A" . $row, "- Line1 \r\n - Line2");
}

$fileName = time().'.xlsx';

$writer = IOFactory::createWriter($spreadSheetObject, 'Xlsx');
$writer->save($fileName);

Used versions of the code:

Note

  • Issue only facing for new line like - Line1 \r\n - Line2
  • For single line value working fine

enter image description here

0

There are 0 answers