Reputation: 309
I want to read/extract the value from HSSFComment. I can access the HSSFComment by the following code:
HSSFComment comment = workSheet.getCellComment(1, 0);
But, how can I get the text/value from that "comment" instance?
there are tow methods in HSSFComment:
getTextObjectRecord()
getNoteRecord()
But both are protected methods...that's why I can't access those from my class. in other word, these methods are not visible from my class. Following line of code doesn't compile.
TextObjectRecord txo = comment.getTextObjectRecord();
Any comments?
Upvotes: 0
Views: 241
Reputation: 86774
Use getString()
inherited from HSSFTextBox
. This returns an HSSFRichTextString
, which itself has a getString()
method to get the plain text. In otherwords
String comment = cell.getComment().getString().getString();
Which you can't do like that due to the possibility of null
returns, but that's the idea.
Upvotes: 1