private static void matchCommentSettings ( final Cell newCell , final Cell sourceCell ) { try { XSSFVMLDrawing sourceVml = getVmlDrawingFromCell ( sourceCell ) ; XSSFVMLDrawing targetVml = getVmlDrawingFromCell ( newCell ) ; CTShape sourceCtShape = getCtShapeFromVml ( sourceCell , sourceVml ) ; CTShape targetCtShape = getCtShapeFromVml ( newCell , targetVml ) ; targetCtShape . setType ( sourceCtShape . getType ( ) ) ; CTClientData sourceClientData = sourceCtShape . getClientDataArray ( 0 ) ; CTClientData targetClientData = targetCtShape . getClientDataArray ( 0 ) ; String [ ] anchorArray = sourceClientData . getAnchorList ( ) . get ( 0 ) . split ( "," ) ; int shiftRows = newCell . getRowIndex ( ) - sourceCell . getRowIndex ( ) ; /* * AchorArray mappings: 0->col1 1->dx1 2->row1 3->dy1 4->col2 5->dx2 6-> row2 * 7->dy2 */ anchorArray [ 2 ] = Integer . toString ( Integer . parseInt ( anchorArray [ 2 ] . trim ( ) ) + shiftRows ) ; anchorArray [ 6 ] = Integer . toString ( Integer . parseInt ( anchorArray [ 6 ] . trim ( ) ) + shiftRows ) ; targetClientData . getAnchorList ( ) . set ( 0 , FacesUtility . strJoin ( anchorArray , "," ) ) ; } catch ( Exception e ) { LOG . log ( Level . SEVERE , "matchCommentSettings error = " + e . getLocalizedMessage ( ) , e ) ; } }
Use low level API to match the comments setting .