use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments in project poi by apache.
the class TestCommentsTable method getCellComment.
@Test
public void getCellComment() throws Exception {
CommentsTable sheetComments = new CommentsTable();
CTComments comments = sheetComments.getCTComments();
CTCommentList commentList = comments.getCommentList();
// Create 2 comments for A1 and A" cells
CTComment comment0 = commentList.insertNewComment(0);
comment0.setRef("A1");
CTRst ctrst0 = CTRst.Factory.newInstance();
ctrst0.setT(TEST_A1_TEXT);
comment0.setText(ctrst0);
CTComment comment1 = commentList.insertNewComment(0);
comment1.setRef("A2");
CTRst ctrst1 = CTRst.Factory.newInstance();
ctrst1.setT(TEST_A2_TEXT);
comment1.setText(ctrst1);
// test finding the right comment for a cell
assertSame(comment0, sheetComments.getCTComment(new CellAddress("A1")));
assertSame(comment1, sheetComments.getCTComment(new CellAddress("A2")));
assertNull(sheetComments.getCTComment(new CellAddress("A3")));
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments in project poi by apache.
the class TestXSSFSheet method setCellComment.
@Test
public void setCellComment() throws IOException {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet();
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();
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()));
workbook.close();
}
Aggregations