org.apache.poi.ss.usermodel.CellStyle.getFontIndex()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(451)

本文整理了Java中org.apache.poi.ss.usermodel.CellStyle.getFontIndex()方法的一些代码示例,展示了CellStyle.getFontIndex()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CellStyle.getFontIndex()方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.CellStyle
类名称:CellStyle
方法名:getFontIndex

CellStyle.getFontIndex介绍

[英]gets the index of the font for this style
[中]获取此样式的字体索引

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

} else {
 Font origFont = data.wb.getFontAt( cell.getCellStyle().getFontIndex() );
 Font hlink_font = data.wb.createFont();

代码示例来源:origin: org.jeecg/easypoi-base

private String styleName(CellStyle style) {
    if (style == null)
      return "";
    return String.format("style_%02x_%s font_%s_%s", style.getIndex(), cssRandom,
      style.getFontIndex(), cssRandom);
  }
}

代码示例来源:origin: zhangdaiscott/jeasypoi

private String styleName(CellStyle style) {
    if (style == null)
      return "";
    return String.format("style_%02x_%s font_%s_%s", style.getIndex(), cssRandom, style.getFontIndex(), cssRandom);
  }
}

代码示例来源:origin: xiaolanglang/easypoi

private String styleName(CellStyle style) {
    if (style == null)
      return "";
    return String.format("style_%02x_%s font_%s_%s", style.getIndex(), cssRandom,
      style.getFontIndex(), cssRandom);
  }
}

代码示例来源:origin: cn.afterturn/easypoi-base

private String styleName(CellStyle style) {
    if (style == null) {
      return "";
    }
    return String.format("style_%02x_%s font_%s_%s", style.getIndex(), cssRandom,
        style.getFontIndex(), cssRandom);
  }
}

代码示例来源:origin: stackoverflow.com

Workbook book = row.getSheet().getWorkbook();
CellStyle style = row.getCell(cellIndex).getCellStyle();
int fontIndex = style.getFontIndex();
Font font = book.getFontAt(fontIndex);
if (font.getBold()) {
  // if you are here, the font is bold
}

代码示例来源:origin: com.b2international.snowowl/com.b2international.snowowl.datastore.server

/**
 * Returns true if the cell (NOT the text inside) is set to bold.
 * @param cell
 * @return
 */
public static boolean isBold(Cell cell) {
  CellStyle style = cell.getCellStyle();
  Workbook workBook = cell.getSheet().getWorkbook();
  Font font = workBook.getFontAt(style.getFontIndex());
  XSSFFont xssfFont = (XSSFFont) font;
  return xssfFont.getBold();
}

代码示例来源:origin: org.spdx/spdx-tools

return 1;
Font font = sheet.getWorkbook().getFontAt(style.getFontIndex());
AttributedString astr = new AttributedString(val);
java.awt.Font awtFont = new java.awt.Font(font.getFontName(), 0, font.getFontHeightInPoints());

代码示例来源:origin: spdx/tools

return 1;
Font font = sheet.getWorkbook().getFontAt(style.getFontIndex());
AttributedString astr = new AttributedString(val);
java.awt.Font awtFont = new java.awt.Font(font.getFontName(), 0, font.getFontHeightInPoints());

代码示例来源:origin: tobyweston/simple-excel

private void applyFontTo(CellStyle style, Workbook workbook) {
    if (fontSize != null) {
      Font font = workbook.createFont();
      font.setFontHeightInPoints(fontSize.value());
      font.setColor(fontColour.value().getPoiStyle());
      style.setFont(font);
    } else {
      // doesn't work
      Font existing = workbook.getFontAt(style.getFontIndex());
      existing.setColor(fontColour.value().getPoiStyle());
      style.setFont(existing);
    }
  }
}

代码示例来源:origin: pentaho/pentaho-reporting

protected HSSFCellStyleKey( final CellStyle style ) {
 this.color = style.getFillForegroundColor();
 this.colorTop = style.getTopBorderColor();
 this.colorLeft = style.getLeftBorderColor();
 this.colorBottom = style.getBottomBorderColor();
 this.colorRight = style.getRightBorderColor();
 this.borderStrokeTop = style.getBorderTopEnum();
 this.borderStrokeLeft = style.getBorderLeftEnum();
 this.borderStrokeBottom = style.getBorderBottomEnum();
 this.borderStrokeRight = style.getBorderRightEnum();
 this.dataStyle = style.getDataFormat();
 this.font = style.getFontIndex();
 this.horizontalAlignment = style.getAlignmentEnum();
 this.verticalAlignment = style.getVerticalAlignmentEnum();
 this.wrapText = style.getWrapText();
 this.textRotation = TextRotation.getInstance( style.getRotation() );
}

代码示例来源:origin: caryyu/excel2pdf

protected Font getFontByExcel(CellStyle style) {
  Workbook wb = excel.getWorkbook();
  short index = style.getFontIndex();
  org.apache.poi.ss.usermodel.Font font = wb.getFontAt(index);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

putShort(properties, FILL_FOREGROUND_COLOR, style.getFillForegroundColor());
putShort(properties, FILL_PATTERN, style.getFillPattern());
putShort(properties, FONT, style.getFontIndex());
putBoolean(properties, HIDDEN, style.getHidden());
putShort(properties, INDENTION, style.getIndention());

代码示例来源:origin: org.apache.poi/poi-contrib

putShort(properties, FILL_FOREGROUND_COLOR, style.getFillForegroundColor());
putShort(properties, FILL_PATTERN, style.getFillPattern());
putShort(properties, FONT, style.getFontIndex());
putBoolean(properties, HIDDEN, style.getHidden());
putShort(properties, INDENTION, style.getIndention());

代码示例来源:origin: com.haulmont.thirdparty/poi

putShort(properties, FILL_FOREGROUND_COLOR, style.getFillForegroundColor());
putShort(properties, FILL_PATTERN, style.getFillPattern());
putShort(properties, FONT, style.getFontIndex());
putBoolean(properties, HIDDEN, style.getHidden());
putShort(properties, INDENTION, style.getIndention());

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

putShort(properties, FILL_FOREGROUND_COLOR, style.getFillForegroundColor());
putShort(properties, FILL_PATTERN, style.getFillPattern());
putShort(properties, FONT, style.getFontIndex());
putBoolean(properties, HIDDEN, style.getHidden());
putShort(properties, INDENTION, style.getIndention());

代码示例来源:origin: net.sf.jxls/jxls-core

newStyle.setFillForegroundColor(style.getFillForegroundColor());
newStyle.setFillPattern(style.getFillPattern());
newStyle.setFont(workbook.getFontAt(style.getFontIndex()));
newStyle.setHidden(style.getHidden());
newStyle.setIndention(style.getIndention());

代码示例来源:origin: SheetJS/jxls

newStyle.setFillForegroundColor(style.getFillForegroundColor());
newStyle.setFillPattern(style.getFillPattern());
newStyle.setFont(workbook.getFontAt(style.getFontIndex()));
newStyle.setHidden(style.getHidden());
newStyle.setIndention(style.getIndention());

代码示例来源:origin: com.eas.platypus/platypus-js-reports

private void copyStyle(Workbook workbook, Cell fromCell, Cell toCell) {
    CellStyle toStyle = toCell.getCellStyle();
    CellStyle fromStyle = fromCell.getCellStyle();
    CellStyle newStyle = workbook.createCellStyle();

    newStyle.setAlignment(fromStyle.getAlignment());
    newStyle.setBorderBottom(fromStyle.getBorderBottom());
    newStyle.setBorderLeft(fromStyle.getBorderLeft());
    newStyle.setBorderRight(fromStyle.getBorderRight());
    newStyle.setBorderTop(fromStyle.getBorderTop());
    newStyle.setBottomBorderColor(fromStyle.getBottomBorderColor());

    newStyle.setFillBackgroundColor(fromStyle.getFillBackgroundColor());
    newStyle.setFillForegroundColor(fromStyle.getFillForegroundColor());
    newStyle.setFillPattern(fromStyle.getFillPattern());
    newStyle.setFont(workbook.getFontAt(fromStyle.getFontIndex()));
    newStyle.setHidden(fromStyle.getHidden());
    newStyle.setIndention(fromStyle.getIndention());
    newStyle.setLeftBorderColor(fromStyle.getLeftBorderColor());
    newStyle.setLocked(fromStyle.getLocked());
    newStyle.setRightBorderColor(fromStyle.getRightBorderColor());
    newStyle.setTopBorderColor(fromStyle.getTopBorderColor());
    newStyle.setVerticalAlignment(fromStyle.getVerticalAlignment());
    newStyle.setWrapText(fromStyle.getWrapText());
    newStyle.setDataFormat(toStyle.getDataFormat());
    toCell.setCellStyle(newStyle);
  }
}

代码示例来源:origin: SheetJS/jxls

private void copyStyle(Workbook workbook, org.apache.poi.ss.usermodel.Cell fromCell, org.apache.poi.ss.usermodel.Cell toCell){
    CellStyle toStyle = toCell.getCellStyle();
    CellStyle fromStyle = fromCell.getCellStyle();
    if( fromStyle.getDataFormat() == toStyle.getDataFormat() ){
      toCell.setCellStyle( fromStyle );
    }else{
      CellStyle newStyle = workbook.createCellStyle();
      newStyle.setAlignment( toStyle.getAlignment() );
      newStyle.setBorderBottom( toStyle.getBorderBottom() );
      newStyle.setBorderLeft( toStyle.getBorderLeft() );
      newStyle.setBorderRight( toStyle.getBorderRight() );
      newStyle.setBorderTop( toStyle.getBorderTop() );
      newStyle.setBottomBorderColor( toStyle.getBottomBorderColor() );
      newStyle.setDataFormat( toStyle.getDataFormat() );
      newStyle.setFillBackgroundColor( fromStyle.getFillBackgroundColor() );
      newStyle.setFillForegroundColor( fromStyle.getFillForegroundColor() );
      newStyle.setFillPattern( fromStyle.getFillPattern() );
      newStyle.setFont( workbook.getFontAt( fromStyle.getFontIndex() ) );
      newStyle.setHidden( toStyle.getHidden() );
      newStyle.setIndention( toStyle.getIndention() );
      newStyle.setLeftBorderColor( toStyle.getLeftBorderColor() );
      newStyle.setLocked( toStyle.getLocked() );
      newStyle.setRightBorderColor( toStyle.getRightBorderColor() );
      newStyle.setTopBorderColor( toStyle.getTopBorderColor() );
      newStyle.setVerticalAlignment( toStyle.getVerticalAlignment() );
      newStyle.setWrapText( toStyle.getWrapText() );
      toCell.setCellStyle( newStyle );
    }
  }
}

相关文章

微信公众号

最新文章

更多