PHPOffice / PhpSpreadsheet

A pure PHP library for reading and writing spreadsheet files
https://phpspreadsheet.readthedocs.io
MIT License
13.35k stars 3.47k forks source link

removeRow with merged Cells apply the same merging to the row below #4077

Open VoigtK opened 4 months ago

VoigtK commented 4 months ago

This is:

- [X] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

removing a row where cells in the row are merged should not merge the cells in the row below

What is the current behavior?

I have a simple file where Row 1 Cells 1 to 4 are merged (Gray highlighted) When removing this row, the Row 2, now Row 1 has its Cells 1 to 4 merged. Although they were not merged before.

Screenshot 2024-06-27 at 10 23 01

What are the steps to reproduce?

<?php

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

// Load file
$reader = IOFactory::createReader(IOFactory::READER_XLSX);
$spreadsheet = $reader->load($file);

// Remove row
$spreadsheet->getActiveSheet()->removeRow(1);

// Save file
$writer = IOFactory::createWriter($spreadsheet, IOFactory::WRITER_XLSX);
$writer->save(substr($file, 0, -5) . '_edited.xlsx');

test.xlsx

What features do you think are causing the issue

Which versions of PhpSpreadsheet and PHP are affected?

PHP 8.3.8 (cli) (built: Jun 4 2024 14:53:17) (NTS) Copyright (c) The PHP Group Zend Engine v4.3.8, Copyright (c) Zend Technologies

"name": "phpoffice/phpspreadsheet",
"version": "2.1.0",
"source": {
     "type": "git",
     "url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
     "reference": "dbed77bd3a0f68f96c0dd68ad4499d5674fecc3e"
},
oleibman commented 3 months ago

Confirmed. I was hoping PR #3528 might address this, but it doesn't.