Skip to content

Row breaks not working when print area is set starting from non-A column #1275

@peterlamfs

Description

@peterlamfs

This is:

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

What is the expected behavior?

After setting print area starting with a non-A column (e.g. B1:B2), calling setBreak('B1', Worksheet::BREAK_ROW) should be able to split B1 and B2 in two different pages.

What is the current behavior?

B1 and B2 appears in the same page in print preview.

To have a correct row break for non-A column, min="1" max="(count of print area columns)" should be added to the <brk> element in xl/worksheets/*.xml. These two attributes can be referred to the XML standard.
https://docs.microsoft.com/en-us/openspecs/office_standards/ms-oe376/b32ae11b-dee7-4dcb-9b46-a0feb32ce94f

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:

<?php

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

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

// add code that show the issue here...
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('B1', 'First Page');
$sheet->setCellValue('B2', 'Second Page');

$sheet->getPageSetup()->setPrintArea('B1:B2');
$sheet->setBreak('B1', \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_ROW);

$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
$writer->save('hello_world.xlsx');

Which versions of PhpSpreadsheet and PHP are affected?

PhpSpreadsheet 1.10.1
PHP 7.2

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