Smoothi
Smoothi

Reputation: 303

Apache POI: comments in empty cells in an empty row

I have a big problem with Apache POI.

    A       B       C       D
1   text    text    text    text
2                   comment           
3   text    text    text    text

In this example row 2 is empty, C2 has no text, but a comment.

If I want to get row 2, POI will return null.

How can I get a comment from an empty cell in an empty row?

Upvotes: 2

Views: 259

Answers (1)

Gagravarr
Gagravarr

Reputation: 48376

To fetch arbitrary comments, without going via the Cell directly, you can use Sheet.gteCellComment(int row, int cell)

From your example, to get the comment in C2, do something like:

CellReference ref = new CellReference("C2")
Comment commentC2 = sheet.getCellComment(ref.getRow(), ref.getCol());

Upvotes: 2

Related Questions