Package org.apache.poi.xssf.model

Examples of org.apache.poi.xssf.model.CommentsTable


                PackageRelationshipCollection commentsRel =
                  part.getRelationshipsByType(SHEET_COMMENTS.REL);
                if(commentsRel != null && commentsRel.size() > 0) {
                  PackagePart commentsPart =
                    getTargetPart(commentsRel.getRelationship(0));
                  comments = new CommentsTable(commentsPart.getInputStream());
                }
               
                // Now create the sheet
                WorksheetDocument worksheetDoc = WorksheetDocument.Factory.parse(part.getInputStream());
                XSSFSheet sheet = new XSSFSheet(ctSheet, worksheetDoc.getWorksheet(), this, comments);
View Full Code Here


                workbook.getSheets().getSheetArray(i).setId(rel.getId());
                workbook.getSheets().getSheetArray(i).setSheetId(sheetNumber);
               
                // If our sheet has comments, then write out those
                if(sheet.hasComments()) {
                  CommentsTable ct = (CommentsTable)sheet.getCommentsSourceIfExists();
                    PackagePartName ctName = PackagingURIHelper.createPartName(
                        SHEET_COMMENTS.getFileName(sheetNumber));
                    part.addRelationship(ctName, TargetMode.INTERNAL, SHEET_COMMENTS.getRelation(), "rComments");
                    PackagePart ctPart = pkg.createPart(ctName, SHEET_COMMENTS.getContentType());
                   
                    out = ctPart.getOutputStream();
                    ct.writeTo(out);
                    out.close();
                }
            }
            
            // Write shared strings and styles
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

        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

    this.sheet = sheet;
  }
 
  private CommentsSource getComments() {
    if (sheetComments == null) {
      sheetComments = new CommentsTable();
    }
    return sheetComments;
  }
View Full Code Here

   
  private static final String TEST_RICHTEXTSTRING = "test richtextstring";
  private static final String TEST_AUTHOR = "test_author";

  public void testConstructors() {
    CommentsTable sheetComments = new CommentsTable();
    XSSFComment comment = sheetComments.addComment();
    assertNotNull(comment);
   
    CTComment ctComment = CTComment.Factory.newInstance();
    XSSFComment comment2 = new XSSFComment(sheetComments, ctComment);
    assertNotNull(comment2);
View Full Code Here

    XSSFComment comment2 = new XSSFComment(sheetComments, ctComment);
    assertNotNull(comment2);
  }
 
  public void testGetColumn() {
    CommentsTable sheetComments = new CommentsTable();
    CTComment ctComment = CTComment.Factory.newInstance();
    ctComment.setRef("A1");
    XSSFComment comment = new XSSFComment(sheetComments, ctComment);
    assertNotNull(comment);
    assertEquals(0, comment.getColumn());
View Full Code Here

    ctComment.setRef("C10");
    assertEquals(2, comment.getColumn());
  }
 
  public void testGetRow() {
    CommentsTable sheetComments = new CommentsTable();
    CTComment ctComment = CTComment.Factory.newInstance();
    ctComment.setRef("A1");
    XSSFComment comment = new XSSFComment(sheetComments, ctComment);
    assertNotNull(comment);
    assertEquals(0, comment.getRow());
View Full Code Here

    CTComment ctComment = ctComments.addNewCommentList().addNewComment();
    CTAuthors ctAuthors = ctComments.addNewAuthors();
    ctAuthors.insertAuthor(0, TEST_AUTHOR);
    ctComment.setAuthorId(0);

    CommentsTable sheetComments = new CommentsTable(ctComments);
    XSSFComment comment = new XSSFComment(sheetComments, ctComment);
    assertNotNull(comment);
    assertEquals(TEST_AUTHOR, comment.getAuthor());
  }
View Full Code Here

    assertNotNull(comment);
    assertEquals(TEST_AUTHOR, comment.getAuthor());
  }
 
  public void testSetColumn() {
    CommentsTable sheetComments = new CommentsTable();
    CTComment ctComment = CTComment.Factory.newInstance();
    XSSFComment comment = new XSSFComment(sheetComments, ctComment);
    comment.setColumn((short)3);
    assertEquals(3, comment.getColumn());
    assertEquals(3, (new CellReference(ctComment.getRef()).getCol()));
View Full Code Here

TOP

Related Classes of org.apache.poi.xssf.model.CommentsTable

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.