The most reliable way to report errors in poi: Multiple cell comments in one cell are not allowed, cell: E3

This problem is that multiple cell comments are not allowed in one cell. The solution is to change from fixed comment settings to using different achors for each cell comment:

private void cellException(Sheet datatypeSheet, CellStyle cellErrorStyle, Row invCurrentRow, int invCellNum, String mainMessage)
{

    Cell mainCell = invCurrentRow.getCell(invCellNum);

    if (ExcelUtility.checkIfCellValueAbsent(mainCell))
        mainCell = invCurrentRow.createCell(invCellNum);

    mainCell.setCellStyle(cellErrorStyle);

    Comment mainComment = mainCell.getCellComment();

    if (Util.isNullOrEmpty(mainComment)){
    
       /** mainComment = datatypeSheet.createDrawingPatriarch().createCellComment(
                new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));*/
                
                new XSSFClientAnchor(0, 0, 0, 0, mainCell.getColumnIndex(), mainCell.getRowIndex(), 					mainCell.getColumnIndex()+2, mainCell.getRowIndex()+3));
    mainComment.setString(new XSSFRichTextString(mainMessage));
    mainCell.setCellComment(mainComment);
    datatypeSheet.autoSizeColumn(mainCell.getColumnIndex());
    }
}

Guess you like

Origin blog.csdn.net/m0_49605579/article/details/126644816