poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hannes Erven <han...@erven.at>
Subject How to find all CellComments in XLS[X]
Date Thu, 03 Sep 2015 12:42:59 GMT
Hi folks,

I need to scan all comments in a given XSLX file (preferably also XLS).
It seems that the only way to access comments is 
Sheet.getCellComment(int row, int column); so I need to find all row and 
cell numbers to iterate through them.

There is just one problem: if a comment is specified outside the range 
of cells in a given row, getFirstCellNum/getLastCellNum only consider 
"present" cells and will ignore comments outside that range.

Consider this simple sheet:
A1: String "Hi"
A2: no values, but a comment
A3: String "there"

For row indizes 0 and 2, getFirstCellNum and getLastCellNum report 0.
For row index 1, they report -1; but getCellComment(1,0) will return the 
comment as expected.

Excel does create a physical row for rows with only a comment, and even 
if there are no additional rows "behind", so it's just a matter of 
detecting the right column ranges to query for a given row.

Anyways, I'd prefer having access to XSSFSheet's "sheetComments" object 
(or similar) and iterate only through the existing comments, rather than 
checking each cell's coordinates, wading through tons of cells just to 
find a handful of comments.

Is there a solution to find all comments? Would it be safe to add public 
access to CommentsTable and/or its commentRefs?

Thanks & best regards,


To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org

View raw message