Package org.apache.poi.xssf.model

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


        doc.setComments(ctComments);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        doc.save(out, POIXMLDocumentPart.DEFAULT_XML_OPTIONS);

        CommentsTable sheetComments = new CommentsTable();
        sheetComments.readFrom(new ByteArrayInputStream(out.toByteArray()));
        XSSFComment comment = new XSSFComment(sheetComments, ctComment);
        assertEquals(TEST_AUTHOR, comment.getAuthor());
    }
View Full Code Here


        XSSFComment comment = new XSSFComment(sheetComments, ctComment);
        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

        comment.setColumn((short)13);
        assertEquals(13, comment.getColumn());
    }

    public void testSetRow() {
        CommentsTable sheetComments = new CommentsTable();
        CTComment ctComment = CTComment.Factory.newInstance();
        XSSFComment comment = new XSSFComment(sheetComments, ctComment);
        comment.setRow(20);
        assertEquals(20, comment.getRow());
        assertEquals(20, (new CellReference(ctComment.getRef()).getRow()));
View Full Code Here

        comment.setRow(19);
        assertEquals(19, comment.getRow());
    }

    public void testSetAuthor() {
        CommentsTable sheetComments = new CommentsTable();
        CTComment ctComment = CTComment.Factory.newInstance();
        XSSFComment comment = new XSSFComment(sheetComments, ctComment);
        comment.setAuthor(TEST_AUTHOR);
        assertEquals(TEST_AUTHOR, comment.getAuthor());
    }
View Full Code Here

        comment.setAuthor(TEST_AUTHOR);
        assertEquals(TEST_AUTHOR, comment.getAuthor());
    }

    public void testSetString() {
        CommentsTable sheetComments = new CommentsTable();
        CTComment ctComment = CTComment.Factory.newInstance();
        XSSFComment comment = new XSSFComment(sheetComments, ctComment);
        RichTextString richTextString = new HSSFRichTextString(TEST_RICHTEXTSTRING);
        comment.setString(richTextString);
        assertEquals(TEST_RICHTEXTSTRING, ctComment.getText().getT());
View Full Code Here

        XSSFSheet sheet = workbook.createSheet();

        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

    public XSSFComment createCellComment(ClientAnchor anchor) {
        XSSFClientAnchor ca = (XSSFClientAnchor)anchor;
        XSSFSheet sheet = (XSSFSheet)getParent();

        //create comments and vmlDrawing parts if they don't exist
        CommentsTable comments = sheet.getCommentsTable(true);
        XSSFVMLDrawing vml = sheet.getVMLDrawing(true);
        schemasMicrosoftComVml.CTShape vmlShape = vml.newCommentShape();
        if(ca.isSet()){
            String position =
                    ca.getCol1() + ", 0, " + ca.getRow1() + ", 0, " +
                    ca.getCol2() + ", 0, " + ca.getRow2() + ", 0";
            vmlShape.getClientDataArray(0).setAnchorArray(0, position);
        }
        XSSFComment shape = new XSSFComment(comments, comments.newComment(), vmlShape);
        shape.setColumn(ca.getCol1());
        shape.setRow(ca.getRow1());
        return shape;
    }
View Full Code Here

    /**
     * test properties of a newly constructed comment
     */
    public void testConstructor() {
        CommentsTable sheetComments = new CommentsTable();
        assertNotNull(sheetComments.getCTComments().getCommentList());
        assertNotNull(sheetComments.getCTComments().getAuthors());
        assertEquals(1, sheetComments.getCTComments().getAuthors().sizeOfAuthorArray());
        assertEquals(1, sheetComments.getNumberOfAuthors());

        CTComment ctComment = sheetComments.newComment();
        CTShape vmlShape = CTShape.Factory.newInstance();

        XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
        assertEquals(null, comment.getString());
        assertEquals(0, comment.getRow());
View Full Code Here

        assertEquals("", comment.getAuthor());
        assertEquals(false, comment.isVisible());
    }

    public void testGetSetCol() {
        CommentsTable sheetComments = new CommentsTable();
        XSSFVMLDrawing vml = new XSSFVMLDrawing();
        CTComment ctComment = sheetComments.newComment();
        CTShape vmlShape = vml.newCommentShape();

        XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
        comment.setColumn(1);
        assertEquals(1, comment.getColumn());
View Full Code Here

        assertEquals(5, new CellReference(ctComment.getRef()).getCol());
        assertEquals(5, vmlShape.getClientDataArray(0).getColumnArray(0).intValue());
    }

    public void testGetSetRow() {
        CommentsTable sheetComments = new CommentsTable();
        XSSFVMLDrawing vml = new XSSFVMLDrawing();
        CTComment ctComment = sheetComments.newComment();
        CTShape vmlShape = vml.newCommentShape();

        XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
        comment.setRow(1);
        assertEquals(1, comment.getRow());
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.