Package org.zkoss.poi.ss.usermodel

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


    BookHelper.setFillForegroundColor(style, newColor);
    cell.setCellStyle(style);
  }
 
  public static void setTextWrap(Worksheet sheet,int row,int col,boolean wrap){
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final boolean textWrap = cell.getCellStyle().getWrapText();
    if (wrap == textWrap) { //no change, skip
      return;
    }
    final CellStyle style = cloneCellStyle(cell);
    style.setWrapText(wrap);
    cell.setCellStyle(style);
  }
View Full Code Here


    style.setWrapText(wrap);
    cell.setCellStyle(style);
  }
 
  public static void setFontSize(Worksheet sheet,int row,int col,int fontHeight){
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final Book book = (Book) sheet.getWorkbook();
    final short fontIdx = cell.getCellStyle().getFontIndex();
    final Font font = book.getFontAt(fontIdx);
    final short orgSize = font.getFontHeight();
    if (orgSize == fontHeight) { //no change, skip
      return;
    }
    final short boldWeight = font.getBoldweight();
    final Color color = BookHelper.getFontColor(book, font);
    final String name = font.getFontName();
    final boolean italic = font.getItalic();
    final boolean strikeout = font.getStrikeout();
    final short typeOffset = font.getTypeOffset();
    final byte underline = font.getUnderline();
    final Font newFont = BookHelper.getOrCreateFont(book, boldWeight, color, (short)fontHeight, name, italic, strikeout, typeOffset, underline);
    final CellStyle style = cloneCellStyle(cell);
    style.setFont(newFont);
    cell.setCellStyle(style);
  }
View Full Code Here

    style.setFont(newFont);
    cell.setCellStyle(style);
  }
 
  public static void setFontStrikethrough(Worksheet sheet,int row,int col, boolean strikeout){
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final Book book = (Book) sheet.getWorkbook();
    final short fontIdx = cell.getCellStyle().getFontIndex();
    final Font font = book.getFontAt(fontIdx);
    final boolean orgStrikeout = font.getStrikeout();
    if (orgStrikeout == strikeout) { //no change, skip
      return;
    }
    final short boldWeight = font.getBoldweight();
    final Color color = BookHelper.getFontColor(book, font);
    final short fontHeight = font.getFontHeight();
    final String name = font.getFontName();
    final boolean italic = font.getItalic();
    final short typeOffset = font.getTypeOffset();
    final byte underline = font.getUnderline();
    final Font newFont = BookHelper.getOrCreateFont(book, boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, underline);
    final CellStyle style = cloneCellStyle(cell);
    style.setFont(newFont);
    cell.setCellStyle(style);
  }
View Full Code Here

    style.setFont(newFont);
    cell.setCellStyle(style);
  }
 
  public static void setFontType(Worksheet sheet,int row,int col,String name){
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final Book book = (Book) sheet.getWorkbook();
    final short fontIdx = cell.getCellStyle().getFontIndex();
    final Font font = book.getFontAt(fontIdx);
    final String orgName = font.getFontName();
    if (orgName.equals(name)) { //no change, skip
      return;
    }
    final short boldWeight = font.getBoldweight();
    final Color color = BookHelper.getFontColor(book, font);
    final short fontHeight = font.getFontHeight();
    final boolean italic = font.getItalic();
    final boolean strikeout = font.getStrikeout();
    final short typeOffset = font.getTypeOffset();
    final byte underline = font.getUnderline();
    final Font newFont = BookHelper.getOrCreateFont(book, boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, underline);
    final CellStyle style = cloneCellStyle(cell);
    style.setFont(newFont);
    cell.setCellStyle(style);
  }
View Full Code Here

  }
  public static void setBorderRight(Worksheet sheet,int row,int col,String color, short linestyle){
    setBorder(sheet,row,col, BookHelper.HTMLToColor(sheet.getWorkbook(), color), linestyle, 0x2);
  }
  public static void setBorder(Worksheet sheet,int row,int col, short color, short lineStyle, int at){
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final CellStyle style = cloneCellStyle(cell);
    if((at & BookHelper.BORDER_EDGE_LEFT)!=0) {
      style.setBorderLeft(lineStyle);
    }
    if((at & BookHelper.BORDER_EDGE_TOP)!=0){
      style.setTopBorderColor(color);
      style.setBorderTop(lineStyle);
    }
    if((at & BookHelper.BORDER_EDGE_RIGHT)!=0){
      style.setRightBorderColor(color);
      style.setBorderRight(lineStyle);
    }
    if((at & BookHelper.BORDER_EDGE_BOTTOM)!=0){
      style.setBottomBorderColor(color);
      style.setBorderBottom(lineStyle);
    }
    cell.setCellStyle(style);
  }
View Full Code Here

    }
    cell.setCellStyle(style);
  }
 
  public static void setBorder(Worksheet sheet,int row,int col, Color color, short lineStyle, int at){
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final CellStyle style = cloneCellStyle(cell);
    if((at & BookHelper.BORDER_EDGE_LEFT)!=0) {
      BookHelper.setLeftBorderColor(style, color);
      style.setBorderLeft(lineStyle);
    }
    if((at & BookHelper.BORDER_EDGE_TOP)!=0){
      BookHelper.setTopBorderColor(style, color);
      style.setBorderTop(lineStyle);
    }
    if((at & BookHelper.BORDER_EDGE_RIGHT)!=0){
      BookHelper.setRightBorderColor(style, color);
      style.setBorderRight(lineStyle);
    }
    if((at & BookHelper.BORDER_EDGE_BOTTOM)!=0){
      BookHelper.setBottomBorderColor(style, color);
      style.setBorderBottom(lineStyle);
    }
    cell.setCellStyle(style);
  }
View Full Code Here

    }
    cell.setCellStyle(style);
  }
 
  public static void setFontBoldWeight(Worksheet sheet,int row,int col,short boldWeight){
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final Book book = (Book) sheet.getWorkbook();
    final short fontIdx = cell.getCellStyle().getFontIndex();
    final Font font = book.getFontAt(fontIdx);
    final short orgBoldWeight = font.getBoldweight();
    if (orgBoldWeight == boldWeight) { //no change, skip
      return;
    }
    final Color color = BookHelper.getFontColor(book, font);
    final short fontHeight = font.getFontHeight();
    final String name = font.getFontName();
    final boolean italic = font.getItalic();
    final boolean strikeout = font.getStrikeout();
    final short typeOffset = font.getTypeOffset();
    final byte underline = font.getUnderline();
    final Font newFont = BookHelper.getOrCreateFont(book, boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, underline);
    final CellStyle style = cloneCellStyle(cell);
    style.setFont(newFont);
    cell.setCellStyle(style);
  }
View Full Code Here

    style.setFont(newFont);
    cell.setCellStyle(style);
  }
 
  public static void setFontItalic(Worksheet sheet, int row, int col, boolean italic) {
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final Book book = (Book) sheet.getWorkbook();
    final short fontIdx = cell.getCellStyle().getFontIndex();
    final Font font = book.getFontAt(fontIdx);
    final boolean orgItalic = font.getItalic();
    if (orgItalic == italic) { //no change, skip
      return;
    }
    final short boldWeight = font.getBoldweight();
    final Color color = BookHelper.getFontColor(book, font);
    final short fontHeight = font.getFontHeight();
    final String name = font.getFontName();
    final boolean strikeout = font.getStrikeout();
    final short typeOffset = font.getTypeOffset();
    final byte underline = font.getUnderline();
    final Font newFont = BookHelper.getOrCreateFont(book, boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, underline);
    final CellStyle style = cloneCellStyle(cell);
    style.setFont(newFont);
    cell.setCellStyle(style);
  }
View Full Code Here

    style.setFont(newFont);
    cell.setCellStyle(style);
  }
 
  public static void setFontUnderline(Worksheet sheet,int row,int col, byte underline){
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final Book book = (Book) sheet.getWorkbook();
    final short fontIdx = cell.getCellStyle().getFontIndex();
    final Font font = book.getFontAt(fontIdx);
    final byte orgUnderline = font.getUnderline();
    if (orgUnderline == underline) { //no change, skip
      return;
    }
    final short boldWeight = font.getBoldweight();
    final Color color = BookHelper.getFontColor(book, font);
    final short fontHeight = font.getFontHeight();
    final String name = font.getFontName();
    final boolean italic = font.getItalic();
    final boolean strikeout = font.getStrikeout();
    final short typeOffset = font.getTypeOffset();
    final Font newFont = BookHelper.getOrCreateFont(book, boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, underline);
    final CellStyle style = cloneCellStyle(cell);
    style.setFont(newFont);
    cell.setCellStyle(style);
  }
View Full Code Here

    style.setFont(newFont);
    cell.setCellStyle(style);
  }
 
  public static void setTextHAlign(Worksheet sheet,int row,int col, short align){
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final short orgAlign = cell.getCellStyle().getAlignment();
    if (align == orgAlign) { //no change, skip
      return;
    }
    final CellStyle style = cloneCellStyle(cell);
    style.setAlignment(align);
    cell.setCellStyle(style);
  }
View Full Code Here

TOP

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

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.