Skip to content

Xlsx reader not recognize data validations that references another sheet - Again #2149

@otargetj2s

Description

@otargetj2s

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?

Load the data validations that references lists of another sheet.

What is the current behavior?

return data validations with none type. Data not loaded for external list.
This regression was reported in early 2018. Never merged.

Excel sample:
sample.xlsx

See links :
#388
#991
#1432

What are the steps to reproduce?

Create a xlsx file with a column with data validation that reference a list of another sheet, then load it in your code.

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 Reader and Spreadsheet object
$reader   = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
$spreadsheet = $reader->load('sample.xlsx');

// add code that show the issue here...
$spreadsheet->setActiveSheetIndexByName('Feuil1');
$worksheet  = $spreadsheet->getActiveSheet();

// internal drop down list: success (type "list")
echo 'B5:DrowDownListType: ', $worksheet->getCell('B5')->getDataValidation()->getType(), "\n";
// external drop down list: failure, data not loaded (type "none" instead of "list")
echo 'B14:DrowDownListType: ', $worksheet->getCell('B14')->getDataValidation()->getType(), "\n";

Which versions of PhpSpreadsheet and PHP are affected?

phpspreadsheet >= 1.6.0
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