Examples of HSSFRichTextString


Examples of org.apache.poi.hssf.usermodel.HSSFRichTextString

                            s.addMergedRegion(region);
                        }


                        cell.setCellValue(
                          new HSSFRichTextString(tmpField.getStringValue()));

                        /* Setup the correct cell formating */
                        HSSFFont tmpFont = wb.createFont();
                        String fontName = tmpField.getFormat().getFont().getFontName();
                        String useFontName = "Times New Roman";
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRichTextString

            cell.setCellStyle(getTimeStyle());
          } else if (values[i] instanceof Calendar) {
            cell.setCellValue((Calendar) values[i]);
            cell.setCellStyle(getTimeStyle());
          } else {
            cell.setCellValue(new HSSFRichTextString((values[i] == null) ? "" : values[i]
                .toString()));
          }
        }
      } else {
        HSSFCell cell = row.createCell(0);
        // cell.setEncoding(HSSFCell.ENCODING_UTF_16);
        if (datas instanceof Number) {
          cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        }
        cell.setCellValue(new HSSFRichTextString(datas.toString()));
      }
    }
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRichTextString

    row = sheet.createRow(0); // 建立新行
    // 显示标题列名
    for (int i = 0; i < pShowKeys.length; i++) {
      cell = row.createCell(i); // 建立新cell
      // cell.setEncoding(HSSFCell.ENCODING_UTF_16);
      cell.setCellValue(new HSSFRichTextString(pShowKeys[i]));
    }
    // 逐行取数
    int rowId = 1;// 数据行号(从2行开始填充数�?)
    for (Iterator<Object[]> iter = datas.iterator(); iter.hasNext(); rowId++) {
      row = sheet.createRow(rowId); // 建立新行
      Object[] objs = iter.next();
      // 生成每一�?
      for (int j = 0; j < objs.length; j++) {
        cell = row.createCell(j); // 建立新cell
        // cell.setEncoding(HSSFCell.ENCODING_UTF_16);
        cell.setCellValue(new HSSFRichTextString((objs[j] == null) ? "" : objs[j].toString()));
      }
    }
    return wb;
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRichTextString

    row = sheet.createRow(0); // 建立新行
    // 显示标题列名�?
    for (int i = 0; i < pShowKeys.length; i++) {
      cell = row.createCell(i); // 建立新cell
      // cell.setEncoding(HSSFCell.ENCODING_UTF_16);
      cell.setCellValue(new HSSFRichTextString(pShowKeys[i]));
    }
    // 逐行取数�?
    int rowId = 1;// 数据行号(从�?2行开始填充数�?)
    for (Iterator<T> iter = list.iterator(); iter.hasNext(); rowId++) {
      row = sheet.createRow(rowId); // 建立新行
      T obj = iter.next();
      // 生成每一
      for (int i = 0; i < pKeys.length; i++) {
        cell = row.createCell(i); // 建立新cell
        cellVal = exporter.getPropertyValue(obj, pKeys[i]);
        // cell.setEncoding(HSSFCell.ENCODING_UTF_16);
        String cellValue = "";
        if (null != cellVal) {
          cellValue = cellVal.toString();
        }
        if (cellVal instanceof Float) {
          cellValue = numberformat.format(cellVal);
        }
        cell.setCellValue(new HSSFRichTextString(cellValue));
      }
    }
    return wb;
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRichTextString

 
  protected final void setStringCellValue(String textStr)
  {
    //cell.setCellValue(JRStringUtil.replaceDosEOL(textStr));
    //cell.setCellValue(textStr);
    cell.setCellValue(new HSSFRichTextString(textStr));
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRichTextString

  }

  protected HSSFRichTextString getRichTextString(JRStyledText styledText, short forecolor, JRFont defaultFont, Locale locale)
  {
    String text = styledText.getText();
    HSSFRichTextString richTextStr = new HSSFRichTextString(text);
    int runLimit = 0;
    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
      Map attributes = iterator.getAttributes();
      JRFont runFont = attributes.isEmpty()? defaultFont : new JRBaseFont(attributes);
      short runForecolor = attributes.get(TextAttribute.FOREGROUND) != null ?
          getWorkbookColor((Color)attributes.get(TextAttribute.FOREGROUND)).getIndex() :
          forecolor;
      HSSFFont font = getLoadedFont(runFont, runForecolor, attributes, locale);
      richTextStr.applyFont(iterator.getIndex(), runLimit, font);
      iterator.setIndex(runLimit);
    }
    return richTextStr;
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRichTextString

  public void write(String value) {
    if (value == null || "null".equals(value)) {
      value = "";
    }
    excelRow.createCell(col).setCellValue(new HSSFRichTextString(value));
    col++;
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRichTextString

        value = "formula";
      case HSSFCell.CELL_TYPE_NUMERIC:
        value = poiCell.getNumericCellValue();
        break;
      case HSSFCell.CELL_TYPE_STRING:
        HSSFRichTextString hssfValue = poiCell.getRichStringCellValue();
        if(hssfValue!=null){
          value = hssfValue.getString();
        }
        break;
      default:
        value = "default";// do nothing
      }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRichTextString

     
      //Ugly, but we can't switch on objects and
      //operator overloading breaks down as we have a handle to a generic 'object'
      if(value!=null &&value instanceof String){
        log.finest("UpdatingCell:"+fact.getCellName()+" value:"+value+" as String");
        HSSFRichTextString textValue=new HSSFRichTextString(value.toString());
        poiCell.setCellValue(textValue);
        poiCell.setCellType(HSSFCell.CELL_TYPE_STRING);
       
       
      } else if(value!=null &&value instanceof Boolean){
        log.finest("UpdatingCell:"+fact.getCellName()+" value:"+value+" as Boolean");
        poiCell.setCellValue((Boolean)fact.getValue());
        poiCell.setCellType(HSSFCell.CELL_TYPE_BOOLEAN);
       
       
      } else if(value!=null &&value instanceof Number){
        log.finest("UpdatingCell:"+fact.getCellName()+" value:"+value+" as Number");
        Double number = ((Number)value).doubleValue();
        poiCell.setCellValue(number);
        poiCell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
       
       
      } else if(value!=null &&value instanceof Date){
       
        //Excel dates are numbers with a special style
        log.finest("UpdatingCell:"+fact.getCellName()+" value:"+value+" as Date");
        Double number = ((Number)value).doubleValue();
        poiCell.setCellValue(number);
        poiCell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
       
        poiCell.getCellStyle().setDataFormat(HSSFDataFormat.getBuiltinFormat(EXCEL_DATE_STYLE));

       
      } else if(value!=null){
       
        //Treat as object, use toString() method
        log.finest("UpdatingCell:"+fact.getCellName()+" value:"+value+" as Generic Object");
        HSSFRichTextString textValue=new HSSFRichTextString(value.toString());
       
        poiCell.setCellValue(textValue);
        poiCell.setCellType(HSSFCell.CELL_TYPE_STRING);
       
      } else {
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRichTextString

    public TextObjectRecord( RecordInputStream in )
    {
        super( in );
        if (str == null)
          str = new HSSFRichTextString("");
    }
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.