import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.usermodel.XSSFComment;
-import org.apache.poi.xssf.usermodel.XSSFRichTextString;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.xssf.usermodel.*;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCommentList;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
Cell c1r2s2 = r2s2.createCell(1);
assertNull(c1r2s2.getCellComment());
- Comment cc2 = sheet2.createComment();
+ Drawing dg = sheet2.createDrawingPatriarch();
+ Comment cc2 = dg.createCellComment(new XSSFClientAnchor());
cc2.setAuthor("Also POI");
cc2.setString(new XSSFRichTextString("A new comment"));
c1r2s2.setCellComment(cc2);
public void testGetCellComment() {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet();
- XSSFComment comment = sheet.createComment();
+ XSSFDrawing dg = sheet.createDrawingPatriarch();
+ XSSFComment comment = dg.createCellComment(new XSSFClientAnchor());
+ XSSFCell cell = sheet.createRow(9).createCell(2);
comment.setAuthor("test C10 author");
- sheet.setCellComment("C10", comment);
+ cell.setCellComment(comment);
assertNotNull(sheet.getCellComment(9, 2));
assertEquals("test C10 author", sheet.getCellComment(9, 2).getAuthor());
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet();
- XSSFComment comment = sheet.createComment();
+ XSSFDrawing dg = sheet.createDrawingPatriarch();
+ XSSFComment comment = dg.createCellComment(new XSSFClientAnchor());
Cell cell = sheet.createRow(0).createCell(0);
CommentsTable comments = sheet.getCommentsTable(false);
CTComments ctComments = comments.getCTComments();
- sheet.setCellComment("A1", comment);
+ cell.setCellComment(comment);
assertEquals("A1", ctComments.getCommentList().getCommentArray(0).getRef());
comment.setAuthor("test A1 author");
assertEquals("test A1 author", comments.getAuthor((int) ctComments.getCommentList().getCommentArray(0).getAuthorId()));