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

Wrong column passed to read filter when reading XLSX file #777

Closed
DennisBirkholz opened this issue Nov 19, 2018 · 0 comments
Closed

Wrong column passed to read filter when reading XLSX file #777

DennisBirkholz opened this issue Nov 19, 2018 · 0 comments

Comments

@DennisBirkholz
Copy link
Contributor

This is:

- [x] a bug report

What is the expected behavior?

Using the XLSX file from tests/data/Reader/XLSX/without_cell_reference.xlsx as the source.

When the default read filter is registered, calls to the readCell() method are performed with the following parameters:

$readFilter->readCell('A', 1, '...');
$readFilter->readCell('B', 1, '...');
$readFilter->readCell('C', 1, '...');
$readFilter->readCell('D', 1, '...');
$readFilter->readCell('E', 1, '...');
...

If a read filter is used that returns false for columns 'B' and 'D', the following calls to readCell() method are performed:

$readFilter->readCell('A', 1, '...');
$readFilter->readCell('B', 1, '...');
$readFilter->readCell('B', 1, '...');
$readFilter->readCell('B', 1, '...');
$readFilter->readCell('B', 1, '...');
...

What is the current behavior?

The method calls to readCell() should use the same parameters as when the default read filter is used.

What are the steps to reproduce?

<?php

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

class TestReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter {
    public function readCell($column, $row, $worksheetName = '')
    {
        return ($column != 'B' && $column != 'D');
    }
}

$filename = 'tests/data/Reader/XLSX/without_cell_reference.xlsx';
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$reader->setReadFilter(new TestReadFilter());
var_dump($reader->load($filename)->getActiveSheet()->toArray());

The outcome should be:

array(10) {
  [0] =>
  array(18) {
    [0] =>
    double(1)
    [1] =>
    NULL
    [2] =>
    double(3)
    [3] =>
    NULL
    [4] =>
    double(5)
    [5] =>
    double(6)
    [6] =>
    double(7)
    [7] =>
    double(8)
    [8] =>
    double(9)
    [9] =>
    double(10)
    [10] =>
    NULL
    [11] =>
    NULL
    [12] =>
    NULL
    [13] =>
    NULL
    [14] =>
    NULL
    [15] =>
    NULL
    [16] =>
    NULL
    [17] =>
    NULL
  }
...

wrong outcome is

array(10) {
  [0] =>
  array(18) {
    [0] =>
    double(1)
    [1] =>
    NULL
    [2] =>
    NULL
    [3] =>
    NULL
    [4] =>
    NULL
    [5] =>
    NULL
    [6] =>
    NULL
    [7] =>
    NULL
    [8] =>
    NULL
    [9] =>
    NULL
    [10] =>
    NULL
    [11] =>
    NULL
    [12] =>
    NULL
    [13] =>
    NULL
    [14] =>
    NULL
    [15] =>
    NULL
    [16] =>
    NULL
    [17] =>
    NULL
  }

Which versions of PhpSpreadsheet and PHP are affected?

PHP 5.6 and PhpSpreadsheet 1.5.0

DennisBirkholz added a commit to PubGrade/PhpSpreadsheet that referenced this issue Nov 19, 2018
DennisBirkholz added a commit to PubGrade/PhpSpreadsheet that referenced this issue Nov 19, 2018
DennisBirkholz added a commit to PubGrade/PhpSpreadsheet that referenced this issue Nov 19, 2018
DennisBirkholz added a commit to PubGrade/PhpSpreadsheet that referenced this issue Nov 19, 2018
guillaume-ro-fr pushed a commit to guillaume-ro-fr/PhpSpreadsheet that referenced this issue Jun 12, 2019
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

1 participant