poi icon indicating copy to clipboard operation
poi copied to clipboard

Read-only Row-like view of columns

Open luca-vercelli opened this issue 4 years ago • 2 comments

I often have to loop over cells of a given column. I think that it would be useful to have an object representing a column. Here, I created the class Column, and I added a method getColumn() in the Sheet interface.

luca-vercelli avatar Aug 02 '19 10:08 luca-vercelli

Can one of the admins verify this patch?

asfgit avatar Aug 02 '19 10:08 asfgit

"obviously" not so much, IMHO. A column /is/ a row, intended as a 1-dimensional array of cells. There are situations where you want to iterate on the cells of a single column.

Il mer 1 apr 2020, 19:54 Dónal Murtagh [email protected] ha scritto:

@donalmurtagh requested changes on this pull request.

In src/java/org/apache/poi/ss/usermodel/Column.java https://github.com/apache/poi/pull/158#discussion_r401802020:

+import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.NotImplemented;

+/**

    • A read-only Row view of a sheet column.
    • Intended to iterate over cells of a sheet.
    • Get this object with Sheet.getColumn(colNum).
    • @author luca vercelli 2018
  • */ +public class Column implements Row {

Row shouldn't be implemented because a column is obviously not a row. On account of implementing this interface there are various methods in this class which don't make any sense

@Override
public int getRowNum() {
    return colNum;
}

@Override
@NotImplemented
public short getHeight() {
    throw new IllegalStateException("Not implemented");
}

@Override
@NotImplemented
public float getHeightInPoints() {
    throw new IllegalStateException("Not implemented");
}

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/apache/poi/pull/158#pullrequestreview-385817979, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACLII2H2UE4TKDWLN3HBIX3RKN5VJANCNFSM4II4V4LQ .

luca-vercelli avatar Apr 01 '20 19:04 luca-vercelli