在导出 excel 文件时,添加批注是一项常见需求。本文将提供 java 代码示例,指导您轻松添加批注,确保批注在导出后不会丢失并与 excel 兼容。
代码示例
// 添加注释 Workbook wb = new Workbook(); IWorksheet worksheet = wb.getActiveSheet(); IComment commentC3 = worksheet.getRange("C3").addComment("C3的注释"); IComment commentC4 = worksheet.getRange("C4").addComment("C4的注释"); IComment commentC5 = worksheet.getRange("C5").addComment("C5的注释"); wb.save("output/memo.xlsx"); // 添加批注 Workbook wb = new Workbook(); IWorksheet sheet = wb.getActiveSheet(); ICommentThreaded ct = sheet.getRange("C3").addCommentThreaded("批注1", "韩梅梅"); ct.addReply("回复1", "李雷"); wb.save("output/comment.xlsx");