Package org.apache.poi.ss.usermodel

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


       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


       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

                    } 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

                    } 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

  public void testBug56017() throws IOException {
      Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56017.xlsx");

        Sheet sheet = wb.getSheetAt(0);

        Comment comment = sheet.getCellComment(0, 0);
        assertNotNull(comment);
        assertEquals("Amdocs", comment.getAuthor());
        assertEquals("Amdocs:\ntest\n", comment.getString().getString());
       
        sheet.shiftRows(0, 1, 1);

        // comment in row 0 is gone
        comment = sheet.getCellComment(0, 0);
        assertNull(comment);
       
        // comment is now in row 1
        comment = sheet.getCellComment(1, 0);
        assertNotNull(comment);
        assertEquals("Amdocs", comment.getAuthor());
        assertEquals("Amdocs:\ntest\n", comment.getString().getString());
       
//        FileOutputStream outputStream = new FileOutputStream("/tmp/56017.xlsx");
//        try {
//            wb.write(outputStream);
//        } finally {
//            outputStream.close();
//        }
       
        Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
        assertNotNull(wbBack);

        Sheet sheetBack = wbBack.getSheetAt(0);

        // comment in row 0 is gone
        comment = sheetBack.getCellComment(0, 0);
        assertNull(comment);

        // comment is now in row 1
        comment = sheetBack.getCellComment(1, 0);
        assertNotNull(comment);
        assertEquals("Amdocs", comment.getAuthor());
        assertEquals("Amdocs:\ntest\n", comment.getString().getString());
  }
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

                        }

                    }

                    // Output the comment in the same cell as the content
                    Comment comment = cell.getCellComment();
                    if (comment != null) {
                        xhtml.characters(comment.getString().getString());
                    }

                    xhtml.endElement("td");
                }
                xhtml.endElement("tr");
View Full Code Here

        anchor.setCol2(c.getColumnIndex() + 7);
        anchor.setRow1(c.getRowIndex());
        anchor.setRow2(c.getRowIndex() + commentLines);

        // Create the comment and set the text+author
        Comment comment = drawing.createCellComment(anchor);
        StringBuilder sb = new StringBuilder();
        String separator = "";
        for (String str : texts) {
            sb.append(separator);
            sb.append(str);
            separator="\n";
        }
        RichTextString str = factory.createRichTextString(sb.toString());
        comment.setString(str);
        comment.setVisible(Boolean.FALSE);
        comment.setAuthor("AlgebraToSpreadsheet");

        // Assign the comment to the cell
        c.setCellComment(comment);
    }
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 "+comment.getAuthor()+": "+commentText);
          }
         
          if(ri.hasNext())
            text.append("\t");
        }
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.