Cell cell = worksheet.getRow(row).getCell(column); Drawing draw = worksheet.createDrawingPatriarch(); Comment comment = draw.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, row, column, 9, 7)); comment.setString(new XSSFRichTextString(message));//设置批注内容 cell.setCellComment(comment); CellStyle cellStyle=workbook.createCellStyle(); cellStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); // 背景色 cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); cell.setCellStyle(cellStyle);
Java POI设置Excel指定单元格添加批注、背景色
最新推荐文章于 2024-07-27 02:31:00 发布