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

Reader\Xlsx - incorrect columnsAttributes and rowsAttributes setting with readFilter #910

Closed
xklid101 opened this issue Feb 27, 2019 · 1 comment
Labels

Comments

@xklid101
Copy link
Contributor

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?

  • apply (set) columnAttributes if AT LEAST ONE row is red by filter
  • apply rowAttributes if at least one column is red by filter

What is the current behavior?

  • columnAttributes are applied only if ALL rows of column are red by filter.
  • rowAttributes - applied only if all columns for particular row is red by filter.

What are the steps to reproduce?

in xml source is (for file /xl/worksheets/sheet1.xml):

...
<cols>
    <col collapsed="false" hidden="false" max="1" min="1" style="0" width="8.17818181818182"/>
    <col collapsed="false" hidden="false" max="2" min="2" style="0" width="55.8981818181818"/>
    <col collapsed="false" hidden="false" max="1025" min="3" style="0" width="8.17818181818182"/>
</cols>
...
<sheetData>
    <row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="17.35" outlineLevel="0" r="12">
        <c r="B12" s="1"/>
    </row>
    ...
    <row collapsed="false" customFormat="false" customHeight="true" hidden="false" ht="19.45" outlineLevel="0" r="43">
        <c r="B43" s="6" t="s">
            <v>25</v>
        </c>
    </row>
    <row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.8" outlineLevel="0" r="1048576"/>
</sheetData>
...

I use following readFilter to read cells

...
public function readCell($column, $row, $worksheetName = '') {
    $r = (int) $row;
    // rows max and min below are int typed already
    if($r > 50 ||
        $r < 10
            return false;

    $col = sprintf("%04s", $column);
    // columns max and min below are sprintf'ed already
    if($col > '000B' ||
        $col < '000Z')
            return false;

    return true;
}
...

e.g. $rowAttribute['rowHeight'] is not set for any row
because column A (and some other columns too) is not among readable columns

Which versions of PhpSpreadsheet and PHP are affected?

phpspreadsheet 1.6.0 (latest master too)
php 5.6, 7.2, 7.3 (tested this three versions)

this is related to #370

My fix for this issue that worked was this (see all foreach loop) Dfred@03d64d3#diff-068dc0d172bdee1daf06b49c7d6b03adR940

And now I see this https://github.com/PHPOffice/PhpSpreadsheet/blob/master/src/PhpSpreadsheet/Reader/Xlsx.php#L2574-L2602

and this caused such behaviour

  • mabye it is not a real bug, but just the matter of opinion

solutions ?

  1. So if you do agree with me - can you apply code (foreach loop) from my referenced diff above?
    or
  2. If you disagree - can you please just change reader private methods to protected, so I can override just one method instead of "copying" the whole class?
@stale
Copy link

stale bot commented Apr 28, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@stale stale bot added the stale label Apr 28, 2019
@stale stale bot closed this as completed May 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant