Examples of RichTextString


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

  private static void createStringCell(Row row, int index, String text,
      ExcelExportEntity entity, Workbook workbook) {
    Cell cell = row.createCell(index);
    switch (entity.getType()) {
    case 1:
      RichTextString Rtext = workbook instanceof HSSFWorkbook ? new HSSFRichTextString(
          text) : new XSSFRichTextString(text);
      cell.setCellValue(Rtext);
      break;
    case 2:
      cell.setCellType(Cell.CELL_TYPE_FORMULA);
View Full Code Here

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

   * @param entity
   */
  private static void createStringCell(Row row, int index, String text,
      CellStyle style, ExcelExportEntity entity) {
    Cell cell = row.createCell(index);
    RichTextString Rtext = new HSSFRichTextString(text);
    cell.setCellValue(Rtext);
    cell.setCellStyle(style);
  }
View Full Code Here

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

      while (it.hasNext()) {
        CgFormFieldEntity type = (CgFormFieldEntity) it.next();
        // 输入需要显示的字段信息
        if (type.getIsShow().equals("Y")) {
          Cell cell = row.createCell(index);
          RichTextString text = new HSSFRichTextString(type
              .getContent());
          cell.setCellValue(text);
          // 设置列宽
          int columnWidth = type.getLength()==0?minColumnWidth:type.getLength()>maxColumnWidth?maxColumnWidth:type.getLength();
          sheet.setColumnWidth(index,256 * columnWidth);
 
View Full Code Here

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

       font1.setColor((short) 20);

       Row row = sheet.createRow(2);
       Cell cell = row.createCell(2);

       RichTextString richTextString =
          wb.getCreationHelper().createRichTextString(text);
      
       // Check the text has the newline
       assertEquals(text, richTextString.getString());
      
       // Apply the font
       richTextString.applyFont(0, 3, font1);
       cell.setCellValue(richTextString);

       // To enable newlines you need set a cell styles with wrap=true
       CellStyle cs = wb.createCellStyle();
       cs.setWrapText(true);
View Full Code Here

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

    Sheet sheet1 = workbook.createSheet("sheet1");
    Sheet sheet2 = workbook.createSheet("sheet2");
    workbook.createSheet("sheet3");

    RichTextString rts = workbook.getCreationHelper().createRichTextString("hello world");

    sheet1.createRow(0).createCell((short)0).setCellValue(1.2);
    sheet1.createRow(1).createCell((short)0).setCellValue(rts);
    sheet2.createRow(0);
View Full Code Here

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

        XSSFRow row = sheet.createRow(0);
        XSSFCell cell = row.createCell(0);

        XSSFFont font = wb.createFont();
        RichTextString rts = factory.createRichTextString("");
        rts.applyFont(font);
        cell.setCellValue(rts);

        sheet.autoSizeColumn(0);
    }
View Full Code Here

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

        AttributedString str;
        TextLayout layout;

        double width = -1;
        if (cellType == Cell.CELL_TYPE_STRING) {
            RichTextString rt = cell.getRichStringCellValue();
            String[] lines = rt.getString().split("\\n");
            for (int i = 0; i < lines.length; i++) {
                String txt = lines[i] + defaultChar;

                str = new AttributedString(txt);
                copyAttributes(font, str, 0, txt.length());

                if (rt.numFormattingRuns() > 0) {
                    // TODO: support rich text fragments
                }

                layout = new TextLayout(str.getIterator(), fontRenderContext);
                if(style.getRotation() != 0){
View Full Code Here

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

                    cell = row.createCell(0);

                    if (r == (rowLimit - 1) && i.hasNext()) {
                        // there are more features than rows available in this
                        // Excel format. write out a warning line and break
                        RichTextString rowWarning = helper.createRichTextString(TRUNCATE_WARNING
                                + ": ROWS " + r + " - " + fc.size() + " NOT SHOWN");
                        cell.setCellValue(rowWarning);
                        cell.setCellStyle(styles.getWarningStyle());
                        break;
                    }
View Full Code Here

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

        XSSFRow row = sheet.createRow(0);
        XSSFCell cell = row.createCell(0);

        XSSFFont font = wb.createFont();
        RichTextString rts = factory.createRichTextString("");
        rts.applyFont(font);
        cell.setCellValue(rts);

        sheet.autoSizeColumn(0);
    }
View Full Code Here

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

        XSSFWorkbook workbook = new XSSFWorkbook();
        Sheet sheet1 = workbook.createSheet("sheet1");
        Sheet sheet2 = workbook.createSheet("sheet2");
        Sheet sheet3 = workbook.createSheet("sheet3");
       
        RichTextString rts = workbook.getCreationHelper().createRichTextString("hello world");
       
        sheet1.createRow(0).createCell((short)0).setCellValue(1.2);
        sheet1.createRow(1).createCell((short)0).setCellValue(rts);
        sheet2.createRow(0);
       
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.