Esempio n. 1
0
    public HSSFCellStyle getOrCreateStyle(HSSFWorkbook workbook, StyleVO styleVO) {
      String keyString = styleVO.toString();
      HSSFCellStyle style = reusableStyles.get(keyString);

      if (style == null) {
        style = workbook.createCellStyle();
        styleVO.applyTo(style, workbook);
        reusableStyles.put(keyString, style);
      }
      return style;
    }
Esempio n. 2
0
    public Object setStyle(Object cellVal, HSSFCell cell, StyleVO styleVal) {
      HSSFWorkbook workbook = cell.getRow().getSheet().getWorkbook();

      if (cellVal instanceof BigDecimal) {
        cellVal = ((BigDecimal) cellVal).doubleValue();
      } else if (cellVal instanceof Float) {
        cellVal = new Double(cellVal.toString());
      }

      HSSFFont font = fonts.getOrCreateFont(workbook, styleVal.fontVal);
      styleVal.fontIndex = font.getIndex();
      cell.setCellStyle(styles.getOrCreateStyle(workbook, styleVal));
      return cellVal;
    }