Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whe I read a spreadsheet with merged cells, no merged cells found #4191

Open
infocube-dev-team opened this issue Oct 15, 2024 · 1 comment
Open

Comments

@infocube-dev-team
Copy link

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?

getMergeCells returns an array with all merged cells in the sheet

What is the current behavior?

getMergeCells returns empty value

What are the steps to reproduce?

<?php

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

// Open Excel file
$spreadSheetFile = "Template.xls"
$reader = IOFactory::createReaderForFile($spreadSheetFile);
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load($spreadSheetFile);

// Get first sheet
$formSheet = $spreadsheet -> getSheet(0);

$merged = $formSheet -> getMergeCells();
if(!empty($merged)) {
    foreach($merged as $merge) {
        var_dump($merge);
    }
}

### What features do you think are causing the issue

- [X] 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?
I don't know.
I tried with the one attached
[Template.xlsx](https://github.com/user-attachments/files/17374218/Template.xlsx)


### Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet 3.3.0
PHP 8.2
@oleibman
Copy link
Collaborator

I believe merge cells are not preserved when you specify ReadDataOnly. Try removing that statement and see what happens.

@PHPOffice PHPOffice deleted a comment Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants
@oleibman @infocube-dev-team and others