Skip to content

Add information about whether the Row is visible or hidden #566

@igorbolic

Description

@igorbolic

Would it be possible to include something like a isHidden / visibility property to the Row object i.e. something similar as it already exists for Sheet as the SheetVisibility info?

My use-case relies on excluding hidden Sheets, but as of recently this should be applied to hidden Rows as well. However, the Row object does not expose any visibility property that would allow such filtering.

As I've seen in reader source code, this should not be a major change and effort i.e. it would be sufficient to include e.g. boolean isHidden property to the Row, and adjust RowSpliterator to include such information during parsing:

// Row.java
    private final int rowNum;
    private final List<Cell> cells;
    private final int physicalCellCount;
    private final boolean isHidden; // NEW: Boolean property 'isHidden' or enum type 'visibility', similarly as in the Sheet object

    Row(int rowNum, int physicalCellCount, List<Cell> cells, boolean isHidden) {
        this.rowNum = rowNum;
        this.physicalCellCount = physicalCellCount;
        this.cells = cells;
        this.isHidden = isHidden; // NEW
    }
...


// RowSpliterator.java

private Row next() throws XMLStreamException {
        if (!"row".equals(r.getLocalName())) {
            throw new NoSuchElementException();
        }

        int trackedColIndex = 0;
        int rowIndex = getRowIndexWithFallback(++trackedRowIndex);

        boolean hidden = "1".equals(r.getAttribute("hidden")); // NEW: Obtain the 'hidden' property of the row

I believe this feature could be beneficial to other users of the library as well.
If needed, I could prepare a quick PR to extend the Row object with visibility information.

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