Package org.zkoss.poi.ss.usermodel

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


    visitCells(sheet, rect, new CellVisitor(){

      @Override
      public void handle(CellVisitorContext context) {
        Font srcFont = context.getFont();
        boolean srcItalic = context.isItalic();

        if (srcItalic != isItalic) {
          final Workbook book = sheet.getWorkbook();
          Font newFont = context.getOrCreateFont(srcFont.getBoldweight(), BookHelper.getFontColor(book, srcFont), srcFont.getFontHeight(), srcFont.getFontName(),
              isItalic, srcFont.getStrikeout(), srcFont.getTypeOffset(), srcFont.getUnderline());
          CellStyle newStyle = context.cloneCellStyle();
          newStyle.setFont(newFont);
          context.getRange().setStyle(newStyle);
        }
View Full Code Here


  public static void setFontUnderline(final Worksheet sheet, Rect rect, final byte underline) {
   
    visitCells(sheet, rect, new CellVisitor(){

      public void handle(CellVisitorContext context) {
        Font srcFont = context.getFont();
        byte srcUnderline = srcFont.getUnderline();

        if (srcUnderline != underline) {
          final Workbook book = sheet.getWorkbook();
          Font newFont = context.getOrCreateFont(srcFont.getBoldweight(), BookHelper.getFontColor(book, srcFont),
            srcFont.getFontHeight(), srcFont.getFontName(),
            srcFont.getItalic(), srcFont.getStrikeout(), srcFont.getTypeOffset(), underline);
          CellStyle newStyle = context.cloneCellStyle();
          newStyle.setFont(newFont);
          context.getRange().setStyle(newStyle);
View Full Code Here

   */
  public static void setFontStrikeout(final Worksheet sheet, Rect rect, final boolean isStrikeout) {
    visitCells(sheet, rect, new CellVisitor(){

      public void handle(CellVisitorContext context) {
        Font srcFont = context.getFont();
        boolean srcStrikeout = srcFont.getStrikeout();
       
        if (srcStrikeout != isStrikeout) {
          final Workbook book = sheet.getWorkbook();
          Font newFont = context.getOrCreateFont(srcFont.getBoldweight(),
              BookHelper.getFontColor(book, srcFont), srcFont.getFontHeight(), srcFont.getFontName(),
              srcFont.getItalic(), isStrikeout, srcFont.getTypeOffset(), srcFont.getUnderline());
          CellStyle cellStyle = context.cloneCellStyle();
          cellStyle.setFont(newFont);
          context.getRange().setStyle(cellStyle);
View Full Code Here

      case CellStyle.VERTICAL_BOTTOM:
        sb.append("vertical-align: bottom;");
        break;
      }
     
      final Font font = _book.getFontAt(style.getFontIndex());
     
      //sb.append(BookHelper.getFontCSSStyle(_book, font));
      sb.append(BookHelper.getFontCSSStyle(_cell, font));

      //condition color
View Full Code Here

 
  public static void setFontColor(Worksheet sheet, int row, int col, String color){
    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 Color orgColor = BookHelper.getFontColor(book, font);
    final Color newColor = BookHelper.HTMLToColor(book, color);
    if (orgColor == newColor || orgColor != null && orgColor.equals(newColor)) {
      return;
    }
    final short boldWeight = font.getBoldweight();
    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, newColor, fontHeight, name, italic, strikeout, typeOffset, underline);
    final CellStyle style = cloneCellStyle(cell);
    style.setFont(newFont);
    cell.setCellStyle(style);
  }
View Full Code Here

 
  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

 
  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

 
  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 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

 
  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

TOP

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

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.