Skip to content

unexpected behavior after Worksheet::removeRow(). #2912

@aungzawhteth10

Description

@aungzawhteth10

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?

No blank page is created.
42-16 rows.
Highest row should be 26.

What is the current behavior?

When the last part of excel is deleted, unwanted rows remain in the printed area, making a blank page.
Highest row is 34.

What are the steps to reproduce?

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

removeRow();
my code
<?php

public function testExcel()
{
        $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
        $excel  = $this->_getTemplateExcel($reader, 'D:\Users\aung.zaw.htet\Desktop\dump\Template.xlsx');
        $sheet = $excel->getSheetByName('Sheet1');
        $sheet->removeRow(35, 8);
        $sheet->removeRow(27, 8);
        error_log(print_r($sheet->getHighestRow(), true ), 3, 'D:/Users/aung.zaw.htet/Desktop/dump/HighestRow.txt');
        $writer     = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($excel, 'Xlsx');
        $writer->save('D:\Users\aung.zaw.htet\Desktop\dump\OutputFile.xlsx');
}

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 Calulations
  • 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?

"phpoffice/phpspreadsheet": "^1.23", PHP 7.4.29
OutputFile.xlsx
[Template.xlsx](https://github.com/PHPOffice/PhpSpreadsheet/files/8990645/Template.xlsx
HighestRow.txt

Metadata

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