public static void cloneComment ( final Cell sourceCell , final Cell newCell ) { XSSFSheet sheet = ( XSSFSheet ) newCell . getSheet ( ) ; CreationHelper factory = sheet . getWorkbook ( ) . getCreationHelper ( ) ; Drawing drawing = sheet . createDrawingPatriarch ( ) ; XSSFComment sourceComment = ( XSSFComment ) sourceCell . getCellComment ( ) ; // Below code are from POI busy manual. // When the comment box is visible, have it show in a 1x3 space ClientAnchor anchor = createCommentAnchor ( newCell , factory ) ; // Create the comment and set the text+author Comment comment = drawing . createCellComment ( anchor ) ; RichTextString str = factory . createRichTextString ( sourceComment . getString ( ) . toString ( ) ) ; comment . setString ( str ) ; comment . setAuthor ( sourceComment . getAuthor ( ) ) ; // Assign the comment to the cell newCell . setCellComment ( comment ) ; comment . setColumn ( newCell . getColumnIndex ( ) ) ; comment . setRow ( newCell . getRowIndex ( ) ) ; // As POI doesn't has well support for comments, // So we have to use low level api to match the comments. matchCommentSettings ( newCell , sourceCell ) ; }
clone existing comments into new cell comment .