org.apache.poi.hssf.usermodel.HSSFFont.setFontHeightInPoints()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(163)

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

HSSFFont.setFontHeightInPoints介绍

[英]set the font height
[中]设置字体高度

代码示例

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

HSSFCellStyle cellStyle = workBook.createCellStyle();        
  HSSFFont font = wb.createFont();
  font.setFontName(XSSFFont.DEFAULT_FONT_NAME);
  font.setFontHeightInPoints((short)10);
  font.setColor(IndexedColors.BLUE.getIndex());
  cellStyle.setFont(font);
 //the version i am using is poi-3.8

代码示例来源:origin: TomasKypta/android-lang-tool

private static HSSFCellStyle createTextStyle(HSSFWorkbook wb) {
  HSSFFont plain = wb.createFont();
  plain.setFontHeightInPoints((short)12);
  HSSFCellStyle textStyle = wb.createCellStyle();
  textStyle.setFont(plain);
  return textStyle;
}

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

private HSSFFont createAndSetFontStyle(HSSFWorkbook wb) {
  HSSFFont font = wb.createFont();
  font.setFontName(XSSFFont.DEFAULT_FONT_NAME);
  font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
  font.setFontHeightInPoints((short)10);
  return font;
}

  HSSFCellStyle cellStyle = workBook.createCellStyle();
  HSSFFont createfont = createAndSetFontStyle(workBook);
  cellStyle.setFont(createfont);

  cell.setCellStyle(cellStyle);

代码示例来源:origin: TomasKypta/android-lang-tool

private static HSSFCellStyle createKeyStyle(HSSFWorkbook wb) {
  HSSFFont bold = wb.createFont();
  bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  bold.setFontHeightInPoints((short)11);
  HSSFCellStyle keyStyle = wb.createCellStyle();
  keyStyle.setFont(bold);
  return keyStyle;
}

代码示例来源:origin: paypal/SeLion

private static HSSFFont createCustomFont(short colorIndex, Byte underlineWeight) {
  HSSFFont font = wb1.createFont();
  font.setFontName(HSSFFont.FONT_ARIAL);
  font.setFontHeightInPoints((short) 10);
  font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  font.setColor(colorIndex);
  font.setUnderline(underlineWeight);
  return font;
}

代码示例来源:origin: io.choerodon/choerodon-starter-core

/**
 * 设置单元格样式
 *
 * @param cellStyle 单元格样式
 * @param book      book HSSFWorkbook对象
 * @author chenssy
 * @date 2014年6月17日 上午11:00:53
 * @version 1.0
 */
private static void setCellStyle(HSSFCellStyle cellStyle, HSSFWorkbook book) {
  cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);   //水平居中
  cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
  HSSFFont font = book.createFont();
  font.setFontHeightInPoints((short) 12);
  cellStyle.setFont(font);
}

代码示例来源:origin: TomasKypta/android-lang-tool

private static HSSFCellStyle createCommentStyle(HSSFWorkbook wb) {
  HSSFFont commentFont = wb.createFont();
  commentFont.setColor(HSSFColor.GREEN.index);
  commentFont.setItalic(true);
  commentFont.setFontHeightInPoints((short)12);
  HSSFCellStyle commentStyle = wb.createCellStyle();
  commentStyle.setFont(commentFont);
  return commentStyle;
}

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

HSSFFont boldFont = wb.createFont();
boldFont.setFontHeightInPoints((short)22);
boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); //Setting Bold font

HSSFCellStyle boldStyle = wb.createCellStyle();
boldStyle.setFont(boldFont); //Attaching the font to the Style

HSSFRow row = sheet1.createRow((short)1);
HSSFCell cell = row.createCell((short)0);
cell.setCellValue("This quick brown fox");
cell.setCellStyle(boldStyle); //Applying Style to the Cell.

代码示例来源:origin: choerodon/choerodon-starters

/**
 * 设置单元格样式
 *
 * @param cellStyle 单元格样式
 * @param book      book HSSFWorkbook对象
 * @author chenssy
 * @date 2014年6月17日 上午11:00:53
 * @version 1.0
 */
private static void setCellStyle(HSSFCellStyle cellStyle, HSSFWorkbook book) {
  cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);   //水平居中
  cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
  HSSFFont font = book.createFont();
  font.setFontHeightInPoints((short) 12);
  cellStyle.setFont(font);
}

代码示例来源:origin: TomasKypta/android-lang-tool

private static HSSFCellStyle createPlurarStyle(HSSFWorkbook wb) {
  HSSFFont commentFont = wb.createFont();
  commentFont.setColor(HSSFColor.GREY_50_PERCENT.index);
  commentFont.setItalic(true);
  commentFont.setFontHeightInPoints((short)12);
  HSSFCellStyle commentStyle = wb.createCellStyle();
  commentStyle.setFont(commentFont);
  return commentStyle;
}

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

font.setFontHeightInPoints((short) 20);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setColor(HSSFColor.BLUE.index);

代码示例来源:origin: io.choerodon/choerodon-starter-core

/**
   * 设置Excel图片的格式:字体居中、变粗、蓝色、12号
   *
   * @param headerStyle 头部样式
   * @param book        生产的excel book      HSSFWorkbook对象
   * @author chenssy
   * @date 2014年6月16日 下午8:46:49
   * @version 1.0
   */
  private static void setHeaderStyle(HSSFCellStyle headerStyle, HSSFWorkbook book) {
    headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);   //水平居中
    headerStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
    //设置字体
    HSSFFont font = book.createFont();
    font.setFontHeightInPoints((short) 12);     //字号:12号
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);   //变粗
    font.setColor(HSSFColor.BLUE.index);   //蓝色

    headerStyle.setFont(font);
  }
}

代码示例来源:origin: choerodon/choerodon-starters

/**
   * 设置Excel图片的格式:字体居中、变粗、蓝色、12号
   *
   * @param headerStyle 头部样式
   * @param book        生产的excel book      HSSFWorkbook对象
   * @author chenssy
   * @date 2014年6月16日 下午8:46:49
   * @version 1.0
   */
  private static void setHeaderStyle(HSSFCellStyle headerStyle, HSSFWorkbook book) {
    headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);   //水平居中
    headerStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
    //设置字体
    HSSFFont font = book.createFont();
    font.setFontHeightInPoints((short) 12);     //字号:12号
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);   //变粗
    font.setColor(HSSFColor.BLUE.index);   //蓝色

    headerStyle.setFont(font);
  }
}

代码示例来源:origin: lanyuancom/lanyuan-2.0

font.setFontName("宋体");
if(position_title.equals(position)){
  font.setFontHeightInPoints((short)11);
  font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
}else{
  font.setFontHeightInPoints((short)10);

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

//////////////////////Excel Header Style/////////////////////////   
   HSSFCellStyle headerlabelcs = wb.createCellStyle();
   headerlabelcs.setFillForegroundColor(HSSFColor.PALE_BLUE.index);
   headerlabelcs.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
   headerlabelcs.setBorderLeft((short)1);
   headerlabelcs.setBorderRight((short)1);
   HSSFFont headerlabelfont = wb.createFont();
   headerlabelfont.setFontHeightInPoints((short)12);
   headerlabelfont.setFontName("Calibri");
   headerlabelfont.setColor(HSSFColor.BLACK.index);
   headerlabelfont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
   headerlabelcs.setFont(headerlabelfont); 
       //////////////////////Excel Header Style/////////////////////////

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

public static void main(String[] args) throws IOException {
    try (HSSFWorkbook wb = new HSSFWorkbook()) {
      HSSFSheet sheet = wb.createSheet("new sheet");

      // Create a row and put some cells in it. Rows are 0 based.
      HSSFRow row = sheet.createRow(1);

      // Create a new font and alter it.
      HSSFFont font = wb.createFont();
      font.setFontHeightInPoints((short) 24);
      font.setFontName("Courier New");
      font.setItalic(true);
      font.setStrikeout(true);

      // Fonts are set into a style so create a new one to use.
      HSSFCellStyle style = wb.createCellStyle();
      style.setFont(font);

      // Create a cell and put a value in it.
      HSSFCell cell = row.createCell(1);
      cell.setCellValue("This is a test of fonts");
      cell.setCellStyle(style);

      // Write the output to a file
      try (FileOutputStream fileOut = new FileOutputStream("workbook.xls")) {
        wb.write(fileOut);
      }
    }
  }
}

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

HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("FirstSheet");
HSSFRow rowhead = sheet.createRow(0); 
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setFontName(HSSFFont.FONT_ARIAL);
font.setFontHeightInPoints((short)10);
font.setBold(true);
style.setFont(font);
rowhead.createCell(0).setCellValue("ID");
rowhead.createCell(1).setCellValue("First");
rowhead.createCell(2).setCellValue("Second");
rowhead.createCell(3).setCellValue("Third");
for(int j = 0; j<=3; j++)
rowhead.getCell(j).setCellStyle(style);

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

boldFont.setFontHeightInPoints((short) 22);
boldFont.setBold(true);

代码示例来源:origin: displaytag/displaytag-export-poi

/**
 * @see org.displaytag.render.TableWriterTemplate#writeCaption(org.displaytag.model.TableModel)
 */
protected void writeCaption(TableModel model) throws Exception
{
  HSSFCellStyle style = this.wb.createCellStyle();
  HSSFFont bold = this.wb.createFont();
  bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  bold.setFontHeightInPoints((short) 14);
  style.setFont(bold);
  style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  this.colNum = 0;
  this.currentRow = this.sheet.createRow(this.rowNum++);
  this.currentCell = this.currentRow.createCell(this.colNum);
  this.currentCell.setCellStyle(style);
  String caption = model.getCaption();
  this.currentCell.setCellValue(new HSSFRichTextString(caption));
  this.rowSpanTable(model);
}

代码示例来源:origin: com.github.hazendaz/displaytag

/**
 * @see org.displaytag.render.TableWriterTemplate#writeCaption(org.displaytag.model.TableModel)
 */
@Override
protected void writeCaption(TableModel model) throws Exception
{
  HSSFCellStyle style = this.wb.createCellStyle();
  HSSFFont bold = this.wb.createFont();
  bold.setBold(true);
  bold.setFontHeightInPoints((short) 14);
  style.setFont(bold);
  style.setAlignment(HorizontalAlignment.CENTER);
  this.colNum = 0;
  this.currentRow = this.sheet.createRow(this.sheetRowNum++);
  this.currentCell = this.currentRow.createCell(this.colNum);
  this.currentCell.setCellStyle(style);
  String caption = model.getCaption();
  this.currentCell.setCellValue(new HSSFRichTextString(caption));
  this.rowSpanTable(model);
}

相关文章