首先拿到前端file控件上传的excel文件,到后台接收!拿到excel这就不多说了网上很多demo的,下面直接说校验单元格追加批注信息的
private void setpz(Workbook work,Sheet sheet,String fileType,String path,int row,int col,String str) throws IOException{
XSSFDrawing p = ((XSSFSheet)sheet).createDrawingPatriarch();
XSSFCell cell = (XSSFCell) sheet.getRow(row).getCell(col);
if(cell == null){//如果你获取的单元格是空进行创建新的cell,再追加批注,不然null指针
XSSFRow r = (XSSFRow) sheet.getRow(row);
cell = r.createCell((short) col);
}
XSSFComment comment = p.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
XSSFRichTextString rtf = new XSSFRichTextString(str);
XSSFFont commentFormatter = (XSSFFont) work.createFont();
rtf.applyFont(commentFormatter);
comment.setString(rtf);
cell.setCellComment(comment);
}
/