Examples of XSSFRichTextString


Examples of org.apache.poi.xssf.usermodel.XSSFRichTextString

        assertEquals(7, sst.getCount());
        assertEquals(3, sst.getUniqueCount());

        //OK. the sst table is filled, check the contents
        assertEquals(3, sst.getItems().size());
        assertEquals("Hello, World!", new XSSFRichTextString(sst.getEntryAt(0)).toString());
        assertEquals("Second string", new XSSFRichTextString(sst.getEntryAt(1)).toString());
        assertEquals("Second string", new XSSFRichTextString(sst.getEntryAt(2)).toString());
    }
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFRichTextString

    text.setT(string.getString());
  }

  public static RichTextString convertFromRst(CTRst ctText) {
    if(ctText == null) {
      return new XSSFRichTextString("");
    }
    if(ctText.getT() != null) {
      return new XSSFRichTextString(ctText.getT());
    }
   
    // Grab all the text
    StringBuffer t = new StringBuffer();
    for(CTRElt r : ctText.getRArray()) {
      t.append( r.getT() );
    }
    XSSFRichTextString rtxt = new XSSFRichTextString(t.toString());
   
    // Now get all the formatting
    // TODO: implement Rst/RpR to RichTextString conversion
    for(CTRElt r : ctText.getRArray()) {
      // Formatting info comes from rPr
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFRichTextString

                        thisStr = '"' + value.toString() + '"';
                        break;

                    case INLINESTR:
                        // TODO: have seen an example of this, so it's untested.
                        XSSFRichTextString rtsi = new XSSFRichTextString(value.toString());
                        thisStr = '"' + rtsi.toString() + '"';
                        break;

                    case SSTINDEX:
                        String sstIndex = value.toString();
                        try {
                            int idx = Integer.parseInt(sstIndex);
                            XSSFRichTextString rtss = new XSSFRichTextString(sharedStringsTable.getEntryAt(idx));
                            thisStr = '"' + rtss.toString() + '"';
                        }
                        catch (NumberFormatException ex) {
                            output.println("Failed to parse SST index '" + sstIndex + "': " + ex.toString());
                        }
                        break;
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFRichTextString

          c.setCellValue("");
        }
        break;
      case TEXT:
        if (cell.getValue() != null) {
          XSSFRichTextString value = new XSSFRichTextString(cell.getValue().toString());
          c.setCellValue(value);
        } else {
          c.setCellType(org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING);
          c.setCellValue("");
        }
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFRichTextString

      logger.warn("Error-cell occurred: {}", _value);
      return _value.toString();
    case FORMULA:
      return _value.toString();
    case INLINESTR:
      XSSFRichTextString rtsi = new XSSFRichTextString(_value.toString());
      return rtsi.toString();
    case SSTINDEX:
      String sstIndex = _value.toString();
      int idx = Integer.parseInt(sstIndex);
      XSSFRichTextString rtss = new XSSFRichTextString(
          _sharedStringTable.getEntryAt(idx));
      return rtss.toString();
    case NUMBER:
      final String numberString = _value.toString();
      if (_formatString != null) {
        DataFormatter formatter = getDataFormatter();
        if (HSSFDateUtil.isADateFormat(_formatIndex, _formatString)) {
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFRichTextString

    // 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
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFRichTextString

                       }
                       break;

                   case INLINE_STRING:
                       // TODO: have seen an example of this, so it's untested.
                       XSSFRichTextString rtsi = new XSSFRichTextString(value.toString());
                       thisStr = rtsi.toString();
                       break;

                   case SST_STRING:
                       String sstIndex = value.toString();
                       try {
                           int idx = Integer.parseInt(sstIndex);
                           XSSFRichTextString rtss = new XSSFRichTextString(sharedStringsTable.getEntryAt(idx));
                           thisStr = rtss.toString();
                       }
                       catch (NumberFormatException ex) {
                           System.err.println("Failed to parse SST index '" + sstIndex + "': " + ex.toString());
                       }
                       break;
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFRichTextString

      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);
      cell.setCellFormula(entity.getCellFormula());
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFRichTextString

      String[] rowvalue = datas.get(i);
      XSSFRow nextrow = sheet.createRow(sheet.getLastRowNum() + 1);// 创建一行
      for (int j = 0; j < rowvalue.length; j++) {
        XSSFCell cell = nextrow
            .createCell(j, XSSFCell.CELL_TYPE_STRING);
        cell.setCellValue(new XSSFRichTextString(rowvalue[j]));
        if (rowvalue[j].equals("Fail")) {
          cell.setCellStyle(styleRed);
        } else if (rowvalue[j].equals("Pass")) {
          cell.setCellStyle(styleGreen);
        } else {
View Full Code Here

Examples of org.apache.poi.xssf.usermodel.XSSFRichTextString

                   }
                   break;

               case INLINE_STRING:
                   // TODO: Can these ever have formatting on them?
                   XSSFRichTextString rtsi = new XSSFRichTextString(value.toString());
                   thisStr = rtsi.toString();
                   break;

               case SST_STRING:
                   String sstIndex = value.toString();
                   try {
                       int idx = Integer.parseInt(sstIndex);
                       XSSFRichTextString rtss = new XSSFRichTextString(sharedStringsTable.getEntryAt(idx));
                       thisStr = rtss.toString();
                   }
                   catch (NumberFormatException ex) {
                       System.err.println("Failed to parse SST index '" + sstIndex + "': " + ex.toString());
                   }
                   break;
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.