Skip to content

Excel range modified to cell A to XFC when calling insertNewRowBefore or removeRow #3308

Closed
@sdespont

Description

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?

When calling $activeSheet->insertNewRowBefore($firstLine+1, $lineCount-1); or $activeSheet->removeRow($firstLine, $lineCount); the cells' range must not be modifed to max cell XFC

I am pretty sure that the problem comes from this PR #3213 driven by issue #3184 after discussing with @MarkBaker. Working well with v1.25.2

What is the current behavior?

Everytime insertNewRowBefore or removeRow is called, the cells' range is modified to the max cell XFC

image

What are the steps to reproduce?

<?php

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

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

$spreadsheet = IOFactory::createReader('Xlsx');
$spreadsheet->setIncludeCharts(true);
$spreadsheet = $objReader->load($filename);

$activeSheet = $spreadsheet->getActiveSheet();
$activeSheet->insertNewRowBefore(1, 10);
$activeSheet->setCellValue('A1', 'ABCDE');

$writer = IOFactory::createWriter($spreadsheet , 'Xlsx');
$writer->save('path);

If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.

What features do you think are causing the issue

  • Reader
  • Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

Which versions of PhpSpreadsheet and PHP are affected?

1.26.0

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions