Package org.openxmlformats.schemas.spreadsheetml.x2006.main

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments


        assertEquals(9, comment.getRow());
    }

    public void testGetAuthor() throws Exception {
        CommentsDocument doc = CommentsDocument.Factory.newInstance();
        CTComments ctComments = CTComments.Factory.newInstance();
        CTComment ctComment = ctComments.addNewCommentList().addNewComment();
        CTAuthors ctAuthors = ctComments.addNewAuthors();
        ctAuthors.insertAuthor(0, TEST_AUTHOR);
        ctComment.setAuthorId(0);
        doc.setComments(ctComments);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here


        XSSFComment comment = sheet.createComment();

        Cell cell = sheet.createRow(0).createCell((short) 0);
        CommentsTable comments = sheet.getCommentsTable();
        CTComments ctComments = comments.getCTComments();

        sheet.setCellComment("A1", 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()));
    }
View Full Code Here

        assertEquals(9, comment.getRow());
    }

    public void testGetAuthor() throws Exception {
        CommentsDocument doc = CommentsDocument.Factory.newInstance();
        CTComments ctComments = CTComments.Factory.newInstance();
        CTComment ctComment = ctComments.addNewCommentList().addNewComment();
        CTAuthors ctAuthors = ctComments.addNewAuthors();
        ctAuthors.insertAuthor(0, TEST_AUTHOR);
        ctComment.setAuthorId(0);
        doc.setComments(ctComments);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

    doc.save(out, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);
    CommentsTable sheetComments = new CommentsTable();
    sheetComments.readFrom(new ByteArrayInputStream(out.toByteArray()));


    CTComments comments = sheetComments.getCTComments();
    CTCommentList commentList = comments.addNewCommentList();

    // Create 2 comments for A1 and A" cells
    CTComment comment0 = commentList.insertNewComment(0);
    comment0.setRef("A1");
    CTRst ctrst0 = CTRst.Factory.newInstance();
View Full Code Here

   
    public void testGetCellComment() {
        XSSFWorkbook workbook = new XSSFWorkbook();
        CTSheet ctSheet = CTSheet.Factory.newInstance();
        CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
        CTComments ctComments = CTComments.Factory.newInstance();
        CommentsTable sheetComments = new CommentsTable(ctComments);
        XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, workbook, sheetComments);
        assertNotNull(sheet);
       
        CTComment ctComment = ctComments.addNewCommentList().insertNewComment(0);
        ctComment.setRef("C10");
        ctComment.setAuthorId(sheetComments.findAuthor("test C10 author"));
       
        assertNotNull(sheet.getCellComment(9, 2));
        assertEquals("test C10 author", sheet.getCellComment(9, 2).getAuthor());
View Full Code Here

        XSSFWorkbook workbook = new XSSFWorkbook();
        CTSheet ctSheet = CTSheet.Factory.newInstance();
        CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
        XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, workbook);
        Cell cell = sheet.createRow(0).createCell((short)0);
        CTComments ctComments = CTComments.Factory.newInstance();
        CommentsTable comments = new CommentsTable(ctComments);
        XSSFComment comment = comments.addComment();
       
        sheet.setCellComment("A1", comment);
        assertEquals("A1", ctComments.getCommentList().getCommentArray(0).getRef());
        comment.setAuthor("test A1 author");
        assertEquals("test A1 author", comments.getAuthor(ctComments.getCommentList().getCommentArray(0).getAuthorId()));
    }
View Full Code Here

   
    public void testGetCellComment() {
        XSSFWorkbook workbook = new XSSFWorkbook();
        CTSheet ctSheet = CTSheet.Factory.newInstance();
        CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
        CTComments ctComments = CTComments.Factory.newInstance();
        CommentsTable sheetComments = new CommentsTable(ctComments);
        XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, workbook, sheetComments);
        assertNotNull(sheet);
       
        // Create C10 cell
        Row row = sheet.createRow(9);
        Cell cell = row.createCell((short)2);
        Cell cell3 = row.createCell((short)3);
       
       
        // Set a comment for C10 cell
        CTComment ctComment = ctComments.addNewCommentList().insertNewComment(0);
        ctComment.setRef("C10");
        ctComment.setAuthorId(sheetComments.findAuthor(TEST_C10_AUTHOR));
       
        assertNotNull(sheet.getRow(9).getCell((short)2));
        assertNotNull(sheet.getRow(9).getCell((short)2).getCellComment());
View Full Code Here

   
    public void testSetCellComment() {
        XSSFWorkbook workbook = new XSSFWorkbook();
        CTSheet ctSheet = CTSheet.Factory.newInstance();
        CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
        CTComments ctComments = CTComments.Factory.newInstance();
        CommentsTable comments = new CommentsTable(ctComments);
        XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, workbook, comments);
        assertNotNull(sheet);
       
        // Create C10 cell
        Row row = sheet.createRow(9);
        Cell cell = row.createCell((short)2);
        Cell cell3 = row.createCell((short)3);
       
        // Create a comment
        Comment comment = comments.addComment();
        comment.setAuthor(TEST_C10_AUTHOR);
       
        // Set a comment for C10 cell
        cell.setCellComment(comment);
       
        CTCell ctCell = ctWorksheet.getSheetData().getRowArray(0).getCArray(0);
    assertNotNull(ctCell);
    assertEquals("C10", ctCell.getR());
    long authorId = ctComments.getCommentList().getCommentArray(0).getAuthorId();
    assertEquals(TEST_C10_AUTHOR, comments.getAuthor(authorId));
    }
View Full Code Here

  private static final String TEST_A2_TEXT = "test A2 text";
  private static final String TEST_A1_TEXT = "test A1 text";
  private static final String TEST_AUTHOR = "test author";

  public void testfindAuthor() {
    CTComments comments = CTComments.Factory.newInstance();
    CommentsTable sheetComments = new CommentsTable(comments);

    assertEquals(0, sheetComments.findAuthor(TEST_AUTHOR));
    assertEquals(1, sheetComments.findAuthor("another author"));
    assertEquals(0, sheetComments.findAuthor(TEST_AUTHOR));
View Full Code Here

    assertEquals(2, sheetComments.findAuthor("YAA"));
    assertEquals(1, sheetComments.findAuthor("another author"));
  }
 
  public void testGetCellComment() {
    CTComments comments = CTComments.Factory.newInstance();
    CommentsTable sheetComments = new CommentsTable(comments);
    CTCommentList commentList = comments.addNewCommentList();
   
    // Create 2 comments for A1 and A" cells
    CTComment comment0 = commentList.insertNewComment(0);
    comment0.setRef("A1");
    CTRst ctrst0 = CTRst.Factory.newInstance();
View Full Code Here

TOP

Related Classes of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.