public static void createOrInsertComment ( final Cell cell , final String commentStr ) { XSSFSheet sheet = ( XSSFSheet ) cell . getSheet ( ) ; CreationHelper factory = sheet . getWorkbook ( ) . getCreationHelper ( ) ; Drawing drawing = sheet . createDrawingPatriarch ( ) ; Comment comment = cell . getCellComment ( ) ; String originStr = "" ; if ( comment == null ) { // Below code are from POI busy manual. // When the comment box is visible, have it show in a 1x3 space ClientAnchor anchor = createCommentAnchor ( cell , factory ) ; // Create the comment and set the text+author comment = drawing . createCellComment ( anchor ) ; } else { originStr = comment . getString ( ) . getString ( ) + "\n" ; } originStr += commentStr ; RichTextString str = factory . createRichTextString ( originStr ) ; comment . setString ( str ) ; comment . setAuthor ( "" ) ; // Assign the comment to the cell cell . setCellComment ( comment ) ; comment . setColumn ( cell . getColumnIndex ( ) ) ; comment . setRow ( cell . getRowIndex ( ) ) ; }
Creates the or insert comment .