Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.Comment


    assertNotNull( r5.getCell(2).getCellComment() );
    assertNotNull( r7.getCell(2).getCellComment() );
   
    // Check they have what we expect
    // TODO: Rich text formatting
    Comment cc5 = r5.getCell(2).getCellComment();
    Comment cc7 = r7.getCell(2).getCellComment();
   
    assertEquals("Nick Burch", cc5.getAuthor());
    assertEquals("Nick Burch:\nThis is a comment", cc5.getString().getString());
    assertEquals(4, cc5.getRow());
    assertEquals(2, cc5.getColumn());
   
    assertEquals("Nick Burch", cc7.getAuthor());
    assertEquals("Nick Burch:\nComment #1\n", cc7.getString().getString());
    assertEquals(6, cc7.getRow());
    assertEquals(2, cc7.getColumn());
  }
View Full Code Here


    assertFalse( ((XSSFSheet)sheet2).hasComments() );
   
    // Change on comment on sheet 1, and add another into
    //  sheet 2
    Row r5 = sheet1.getRow(4);
    Comment cc5 = r5.getCell(2).getCellComment();
    cc5.setAuthor("Apache POI");
    cc5.setString(new XSSFRichTextString("Hello!"));
   
    Row r2s2 = sheet2.createRow(2);
    Cell c1r2s2 = r2s2.createCell(1);
    assertNull(c1r2s2.getCellComment());
   
    Comment cc2 = sheet2.createComment();
    cc2.setAuthor("Also POI");
    cc2.setString(new XSSFRichTextString("A new comment"));
    c1r2s2.setCellComment(cc2);
   
   
    // Save, and re-load the file
        workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
View Full Code Here

        Cell r1c1 = r1.createCell(0);
        r1c1.setCellValue(2.2);

        assertEquals(0, s1.getNumberOfComments());

        Comment c1 = s1.createComment();
        c1.setAuthor("Author 1");
        c1.setString(new XSSFRichTextString("Comment 1"));
        r1c1.setCellComment(c1);

        assertEquals(1, s1.getNumberOfComments());

        // Save and re-load
        wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
        s1 = wb.getSheetAt(0);

        assertEquals(1, s1.getNumberOfComments());
        assertNotNull(s1.getRow(0).getCell(0).getCellComment());
        assertEquals("Author 1", s1.getRow(0).getCell(0).getCellComment().getAuthor());
        assertEquals("Comment 1", s1.getRow(0).getCell(0).getCellComment().getString().getString());

        // Now add an orphaned one
        Comment c2 = s1.createComment();
        c2.setAuthor("Author 2");
        c2.setString(new XSSFRichTextString("Second Comment"));
        c2.setRow(0);
        c2.setColumn((short)1);
        assertEquals(2, s1.getNumberOfComments());

        // Save and re-load

        wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
View Full Code Here

    assertNotNull( r5.getCell(2).getCellComment() );
    assertNotNull( r7.getCell(2).getCellComment() );

    // Check they have what we expect
    // TODO: Rich text formatting
    Comment cc5 = r5.getCell(2).getCellComment();
    Comment cc7 = r7.getCell(2).getCellComment();

    assertEquals("Nick Burch", cc5.getAuthor());
    assertEquals("Nick Burch:\nThis is a comment", cc5.getString().getString());
    assertEquals(4, cc5.getRow());
    assertEquals(2, cc5.getColumn());

    assertEquals("Nick Burch", cc7.getAuthor());
    assertEquals("Nick Burch:\nComment #1\n", cc7.getString().getString());
    assertEquals(6, cc7.getRow());
    assertEquals(2, cc7.getColumn());
  }
View Full Code Here

        Cell r1c1 = r1.createCell(0);
        r1c1.setCellValue(2.2);

        assertEquals(0, s1.getNumberOfComments());

        Comment c1 = s1.createComment();
        c1.setAuthor("Author 1");
        c1.setString(new XSSFRichTextString("Comment 1"));
        r1c1.setCellComment(c1);

        assertEquals(1, s1.getNumberOfComments());

        // Save and re-load
        wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
        s1 = wb.getSheetAt(0);

        assertEquals(1, s1.getNumberOfComments());
        assertNotNull(s1.getRow(0).getCell(0).getCellComment());
        assertEquals("Author 1", s1.getRow(0).getCell(0).getCellComment().getAuthor());
        assertEquals("Comment 1", s1.getRow(0).getCell(0).getCellComment().getString().getString());

        // Now add an orphaned one
        Comment c2 = s1.createComment();
        c2.setAuthor("Author 2");
        c2.setString(new XSSFRichTextString("Second Comment"));
        c2.setRow(0);
        c2.setColumn((short)1);
        assertEquals(2, s1.getNumberOfComments());

        // Save and re-load

        wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
View Full Code Here

    assertFalse( sheet2.hasComments() );

    // Change on comment on sheet 1, and add another into
    //  sheet 2
    Row r5 = sheet1.getRow(4);
    Comment cc5 = r5.getCell(2).getCellComment();
    cc5.setAuthor("Apache POI");
    cc5.setString(new XSSFRichTextString("Hello!"));

    Row r2s2 = sheet2.createRow(2);
    Cell c1r2s2 = r2s2.createCell(1);
    assertNull(c1r2s2.getCellComment());

    Comment cc2 = sheet2.createComment();
    cc2.setAuthor("Also POI");
    cc2.setString(new XSSFRichTextString("A new comment"));
    c1r2s2.setCellComment(cc2);


    // Save, and re-load the file
    workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
View Full Code Here

            XSSFCell xc = (XSSFCell)cell;
            text.append(xc.getRawValue());
          }

          // Output the comment, if requested and exists
            Comment comment = cell.getCellComment();
          if(includeCellComments && comment != null) {
              // Replace any newlines with spaces, otherwise it
              //  breaks the output
              String commentText = comment.getString().getString().replace('\n', ' ');
              text.append(" Comment by ").append(comment.getAuthor()).append(": ").append(commentText);
          }

          if(ri.hasNext())
            text.append("\t");
        }
View Full Code Here

            XSSFCell xc = (XSSFCell)cell;
            text.append(xc.getRawValue());
          }

          // Output the comment, if requested and exists
            Comment comment = cell.getCellComment();
          if(includeCellComments && comment != null) {
              // Replace any newlines with spaces, otherwise it
              //  breaks the output
              String commentText = comment.getString().getString().replace('\n', ' ');
              text.append(" Comment by ").append(comment.getAuthor()).append(": ").append(commentText);
          }

          if(ri.hasNext())
            text.append("\t");
        }
View Full Code Here

                    } else {
                        handleNonStringCell(text, cell, formatter);
                    }

                    // Output the comment, if requested and exists
                    Comment comment = cell.getCellComment();
                    if(includeCellComments && comment != null) {
                        // Replace any newlines with spaces, otherwise it
                        //  breaks the output
                        String commentText = comment.getString().getString().replace('\n', ' ');
                        text.append(" Comment by ").append(comment.getAuthor()).append(": ").append(commentText);
                    }

                    if(ri.hasNext())
                        text.append("\t");
                }
View Full Code Here

       anchor.setCol1(0);
       anchor.setCol2(4);
       anchor.setRow1(0);
       anchor.setRow2(1);

       Comment comment1 = drawing.createCellComment(anchor);
       comment1.setString(
             factory.createRichTextString("I like this cell. It's my favourite."));
       comment1.setAuthor("Bob T. Fish");
      
       Comment comment2 = drawing.createCellComment(anchor);
       comment2.setString(
             factory.createRichTextString("This is much less fun..."));
       comment2.setAuthor("Bob T. Fish");

       Cell c1 = sh1.getRow(0).createCell(4);
       c1.setCellValue(2.3);
       c1.setCellComment(comment1);
      
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.Comment

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.