Package org.zkoss.poi.ss.usermodel

Examples of org.zkoss.poi.ss.usermodel.CellStyle


      return "#000000";
    return  color;
  }
 
  public static String getBackgroundHTMLColor(Cell cell) {
    CellStyle cellStyle = cell.getCellStyle();
    Book book = (Book)cell.getSheet().getWorkbook();
    //bug#ZSS-34: cell background color does not show in excel
    String color = cellStyle.getFillPattern() != CellStyle.NO_FILL ?
        BookHelper.colorToHTML(book, cellStyle.getFillForegroundColorColor()) : null;
    if (color == null || BookHelper.AUTO_COLOR.equals(color))
      return "#FFFFFF";
    return color;
  }
View Full Code Here


  @Test
  public void testSetBgColor() {
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Cell A1 = BookHelper.getOrCreateCell(sheet1, 0, 0);
    CellStyle newCellStyle = _workbook.createCellStyle();
    newCellStyle.cloneStyleFrom(A1.getCellStyle());
    final Color bsColor = BookHelper.HTMLToColor(_workbook, "#00FF00");
    BookHelper.setFillForegroundColor(newCellStyle, bsColor);
    BookHelper.setCellStyle(sheet1, 0, 0, 0, 0, newCellStyle);
    assertEquals("FF00FF00", ((XSSFColor)row1.getCell(0).getCellStyle().getFillForegroundColorColor()).getARGBHex()); //A1: Green
  }
View Full Code Here

          @Override
          public void handle(CellVisitorContext context) {
            final short srcAlign = context.getVerticalAlignment();

            if (srcAlign != alignment) {
              CellStyle newStyle = context.cloneCellStyle();
              newStyle.setVerticalAlignment(alignment);
              context.getRange().setStyle(newStyle);
            }
          }})
      } else {
        showProtectMessage();
View Full Code Here

          @Override
          public void handle(CellVisitorContext context) {
            final short srcAlign = context.getAlignment();

            if (srcAlign != alignment) {
              CellStyle newStyle = context.cloneCellStyle();
              newStyle.setAlignment(alignment);
              context.getRange().setStyle(newStyle);
            }
          }})
      } else {
        showProtectMessage();
View Full Code Here

      }
    }
  }

  protected void clearStyleImp(Rect selection, Worksheet worksheet) {
    final CellStyle defaultStyle = worksheet.getBook().createCellStyle();
    Ranges
    .range(worksheet, selection.getTop(), selection.getLeft(),selection.getBottom(), selection.getRight())
    .setStyle(defaultStyle);
  }
View Full Code Here

TOP

Related Classes of org.zkoss.poi.ss.usermodel.CellStyle

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.