Package org.zkoss.poi.ss.usermodel

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


    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final short orgValign = cell.getCellStyle().getVerticalAlignment();
    if (valign == orgValign) { //no change, skip
      return;
    }
    final CellStyle style = cloneCellStyle(cell);
    style.setAlignment(valign);
    cell.setCellStyle(style);
  }
View Full Code Here


  public String getHtmlStyle() {

    StringBuffer sb = new StringBuffer();
    if (_cell != null) {
      final CellStyle style = _cell.getCellStyle();
     
      if (style == null)
        return "";

       
     
      //String bgColor = BookHelper.indexToRGB(_book, style.getFillForegroundColor());
      //ZSS-34 cell background color does not show in excel
      //20110819, henrichen: if fill pattern is NO_FILL, shall not show the cell background color
      String bgColor = style.getFillPattern() != CellStyle.NO_FILL ?
        BookHelper.colorToHTML(_book, style.getFillForegroundColorColor()) : null;
      if (BookHelper.AUTO_COLOR.equals(bgColor)) {
        bgColor = null;
      }
      if (bgColor != null) {
        sb.append("background-color:").append(bgColor).append(";");
View Full Code Here

  private boolean processBottomBorder(StringBuffer sb) {

    boolean hitBottom = false;

    if (_cell != null) {
      CellStyle style = _cell.getCellStyle();
     
     
      if (style != null){
        int bb = style.getBorderBottom();
        //String color = BookHelper.indexToRGB(_book, style.getBottomBorderColor());
        String color = BookHelper.colorToHTML(_book, style.getBottomBorderColorColor());
        hitBottom = appendBorderStyle(sb, "bottom", bb, color);
      }
    }
    Cell next = null;
    if (!hitBottom) {
      next = Utils.getCell(_sheet, _row + 1, _col);
      /*if(next == null){ // don't search into merge ranges
        //check is _row+1,_col in merge range
        MergedRect rect = _mmHelper.getMergeRange(_row+1, _col);
        if(rect !=null){
          next = _sheet.getCell(rect.getTop(),rect.getLeft());
        }
      }*/
      if (next != null) {
        CellStyle style = next.getCellStyle();
        if (style != null){
          int bb = style.getBorderTop();// get top border of
          //String color = BookHelper.indexToRGB(_book, style.getTopBorderColor());
          String color = BookHelper.colorToHTML(_book, style.getTopBorderColorColor());
          // set next row top border as cell's bottom border;
          hitBottom = appendBorderStyle(sb, "bottom", bb, color);
        }
      }
    }
   
    //border depends on next cell's background color
    if(!hitBottom && next !=null){
      CellStyle style = next.getCellStyle();
      if (style != null){
        //String bgColor = BookHelper.indexToRGB(_book, style.getFillForegroundColor());
        //ZSS-34 cell background color does not show in excel
        String bgColor = style.getFillPattern() != CellStyle.NO_FILL ?
            BookHelper.colorToHTML(_book, style.getFillForegroundColorColor()) : null;
        if (BookHelper.AUTO_COLOR.equals(bgColor)) {
          bgColor = null;
        }
        if (bgColor != null) {
          hitBottom = appendBorderStyle(sb, "bottom", CellStyle.BORDER_THIN, bgColor);
        }
      }
    }
   
    //border depends on current cell's background color
    if(!hitBottom && _cell !=null){
      CellStyle style = _cell.getCellStyle();
     
      if (style != null){
        //String bgColor = BookHelper.indexToRGB(_book, style.getFillForegroundColor());
        //ZSS-34 cell background color does not show in excel
        String bgColor = style.getFillPattern() != CellStyle.NO_FILL ?
            BookHelper.colorToHTML(_book, style.getFillForegroundColorColor()) : null;
        if (BookHelper.AUTO_COLOR.equals(bgColor)) {
          bgColor = null;
        }
        if (bgColor != null) {
          hitBottom = appendBorderStyle(sb, "bottom", CellStyle.BORDER_THIN, bgColor);
View Full Code Here

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

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

      Worksheet sheet = spreadsheet.getSelectedSheet();
      for (int row = top; row <= bottom; row++) {
        for (int col = left; col <= right; col++) {
          final Cell cell = Utils.getCell(sheet, row, col);
          if (cell != null) {
            CellStyle cs = cell.getCellStyle();
            cs.setHidden(mfp_hidden.isChecked());
            cs.setLocked(mfp_hidden.isChecked());
            //Styles.setLocked(sheet, row, col, mfp_locked.isChecked());
            //Styles.setHidden(sheet, row, col, mfp_hidden.isChecked());
          }
        }
      }
View Full Code Here

      if (clipboard.type == Clipboard.Type.CUT) {
        Ranges
        .range(srcSheet, srcRect.getTop(), srcRect.getLeft(), srcRect.getBottom(), srcRect.getRight())
        .clearContents();
       
        final CellStyle defaultStyle = clipboard.book.createCellStyle();
        Ranges
        .range(srcSheet, srcRect.getTop(), srcRect.getLeft(),srcRect.getBottom(), srcRect.getRight())
        .setStyle(defaultStyle);
       
        ss.getActionHandler().clearClipboard();
View Full Code Here

  public static Font getFont(Cell cell) {
    if (cell == null)
      return null;
   
    Book book = (Book)cell.getSheet().getWorkbook();
    CellStyle cellStyle = cell.getCellStyle();
    return book.getFontAt(cellStyle.getFontIndex());
  }
View Full Code Here

  public static boolean isBold(Font font) {
    return font.getBoldweight() == Font.BOLDWEIGHT_BOLD;
  }
 
  public static boolean isAlignLeft(Cell cell) {
    CellStyle cellStyle = cell.getCellStyle();
    return cellStyle.getAlignment() == CellStyle.ALIGN_LEFT;
  }
View Full Code Here

    CellStyle cellStyle = cell.getCellStyle();
    return cellStyle.getAlignment() == CellStyle.ALIGN_LEFT;
  }
 
  public static boolean isAlignCenter(Cell cell) {
    CellStyle cellStyle = cell.getCellStyle();
    return cellStyle.getAlignment() == CellStyle.ALIGN_CENTER;
  }
View Full Code Here

    CellStyle cellStyle = cell.getCellStyle();
    return cellStyle.getAlignment() == CellStyle.ALIGN_CENTER;
  }

  public static boolean isAlignRight(Cell cell) {
    CellStyle cellStyle = cell.getCellStyle();
    return cellStyle.getAlignment() == CellStyle.ALIGN_RIGHT;
  }
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.