package javatest; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFClientAnchor; import org.apache.poi.xssf.usermodel.XSSFComment; import org.apache.poi.xssf.usermodel.XSSFDrawing; import org.apache.poi.xssf.usermodel.XSSFRichTextString; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class PoiWriter { public static void main (String [] args) throws IOException { // create a workbook object XSSFWorkbook wb = new new XSSFWorkbook (); // create a worksheet object XSSFSheet sheet = wb.createSheet ( "My Worksheet" ); // object creation XSSFDrawing P = sheet.createDrawingPatriarch (); // create a cell object, annotation 4 is inserted into the row, one, B5 cell XSSFCell cell = sheet.createRow (4) .createCell (. 1 ); // insert cell contents cell.setCellValue ( new newXSSFRichTextString ( "comments" )); // Get annotation objects // (int DX1, Dy1-int, int DX2, int Dy2, Short col1, int ROW1, Short // col2, int ROW2) // The first four parameters are the coordinates point, the four parameters are edited and displayed when the size of the annotation. XSSFComment Comment = p.createCellComment ( new new XSSFClientAnchor (0, 0, 0,0, ( Short ). 3,. 3, ( Short ). 5,. 6 )); / / input annotation information comment.setString ( new new XSSFRichTextString ( "this is the annotation content!" )); // add authors, select cell B5, look at the status bar comment.setAuthor ( "Toad" ); // add annotations to the unit grid object cell.setCellComment (Comment); // create output stream a FileOutputStream OUT = new new a FileOutputStream ( "D: /writerPostil.xlsx" ); wb.write(out); // Close stream object the out.close (); } }
2003 has not been tested.
http://seymours.cn/articles/2018/09/30/1538293323698.html
https://blog.csdn.net/u012959498/article/details/78413265