Examples of XSSFComment


Examples of org.apache.poi.xssf.usermodel.XSSFComment

      throw new AssertionFailedError("didn't find comments table");
    }
    assertEquals(2, ct.getNumberOfComments());
    assertEquals(1, ct.getNumberOfAuthors());

    XSSFComment comment = ct.findCellComment("C5");

    assertEquals("Nick Burch", comment.getAuthor());
    assertEquals("Nick Burch:\nThis is a comment", comment.getString().getString());

    wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
    rels = wb.getSheetAt(0).getRelations();
    ct = null;
    for(POIXMLDocumentPart p : rels) {
      if(p instanceof CommentsTable){
        ct = (CommentsTable)p;
        break;
      }
    }
    if (ct == null) {
      throw new AssertionFailedError("didn't find comments table");
    }

    assertEquals(2, ct.getNumberOfComments());
    assertEquals(1, ct.getNumberOfAuthors());

    comment = ct.findCellComment("C5");

    assertEquals("Nick Burch", comment.getAuthor());

    assertEquals("Nick Burch:\nThis is a comment", comment.getString().getString());
  }
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFComment

    }

    public XSSFComment findCellComment(String cellRef) {
        for (CTComment comment : getCommentsList().getCommentArray()) {
            if (cellRef.equals(comment.getRef())) {
                return new XSSFComment(this, comment);
            }
        }
        return null;
    }
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFComment

    /**
     * Generates a new XSSFComment, associated with the
     *  current comments list.
     */
    public XSSFComment addComment() {
        return new XSSFComment(this, getCommentsList().addNewComment());
    }
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFComment

        return addNewAuthor(author);
    }

    public XSSFComment findCellComment(String cellRef) {
        CTComment ct = getCTComment(cellRef);
        return ct == null ? null : new XSSFComment(this, ct, null);
    }
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFComment

        return addNewAuthor(author);
    }

    public XSSFComment findCellComment(String cellRef) {
        CTComment ct = getCTComment(cellRef);
        return ct == null ? null : new XSSFComment(this, ct, null);
    }
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFComment

  }
 
  public XSSFComment findCellComment(String cellRef) {
    for (CTComment comment : getCommentsList().getCommentArray()) {
      if (cellRef.equals(comment.getRef())) {
        return new XSSFComment(this, comment);
      }
    }
    return null;
  }
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFComment

  /**
   * Generates a new XSSFComment, associated with the
   *  current comments list.
   */
  public XSSFComment addComment() {
    return new XSSFComment(this, getCommentsList().addNewComment());
  }
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFComment

    CTComments comments = CTComments.Factory.newInstance();
    CommentsTable sheetComments = new CommentsTable(comments);
    CTCommentList commentList = comments.addNewCommentList();
    assertEquals(0, commentList.sizeOfCommentArray());
   
    XSSFComment comment = sheetComments.addComment();
    comment.setAuthor("test A1 author");
    comment.setRow(0);
    comment.setColumn((short)0);
   
    assertEquals(1, commentList.sizeOfCommentArray());
    assertEquals("test A1 author", sheetComments.getAuthor(commentList.getCommentArray(0).getAuthorId()));
    assertEquals("test A1 author", comment.getAuthor());
   
    // Change the author, check it updates
    comment.setAuthor("Another Author");
    assertEquals(1, commentList.sizeOfCommentArray());
    assertEquals("Another Author", comment.getAuthor());
  }
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFComment

   
    CommentsTable ct = new CommentsTable(cpart.getInputStream());
    assertEquals(2, ct.getNumberOfComments());
    assertEquals(1, ct.getNumberOfAuthors());

    XSSFComment comment = ct.findCellComment("C5");
   
    assertEquals("Nick Burch", comment.getAuthor());
    assertEquals("Nick Burch:\nThis is a comment", comment.getString().getString());
   
    // Re-serialise
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ct.writeTo(baos);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    ct = new CommentsTable(bais);
   
    assertEquals(2, ct.getNumberOfComments());
    assertEquals(1, ct.getNumberOfAuthors());
   
    comment = ct.findCellComment("C5");
   
    assertEquals("Nick Burch", comment.getAuthor());
   
    // TODO: Fix this!
    // New line should still be there, but isn't!
    //assertEquals("Nick Burch:\nThis is a comment", comment.getString().getString());
  }
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFComment

        return addNewAuthor(author);
    }

    public XSSFComment findCellComment(String cellRef) {
        CTComment ct = getCTComment(cellRef);
        return ct == null ? null : new XSSFComment(this, ct, null);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.