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

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

本文整理了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

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

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

  1. private static HSSFCellStyle createTextStyle(HSSFWorkbook wb) {
  2. HSSFFont plain = wb.createFont();
  3. plain.setFontHeightInPoints((short)12);
  4. HSSFCellStyle textStyle = wb.createCellStyle();
  5. textStyle.setFont(plain);
  6. return textStyle;
  7. }

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

  1. private HSSFFont createAndSetFontStyle(HSSFWorkbook wb) {
  2. HSSFFont font = wb.createFont();
  3. font.setFontName(XSSFFont.DEFAULT_FONT_NAME);
  4. font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
  5. font.setFontHeightInPoints((short)10);
  6. return font;
  7. }
  8. HSSFCellStyle cellStyle = workBook.createCellStyle();
  9. HSSFFont createfont = createAndSetFontStyle(workBook);
  10. cellStyle.setFont(createfont);
  11. cell.setCellStyle(cellStyle);

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

  1. private static HSSFCellStyle createKeyStyle(HSSFWorkbook wb) {
  2. HSSFFont bold = wb.createFont();
  3. bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  4. bold.setFontHeightInPoints((short)11);
  5. HSSFCellStyle keyStyle = wb.createCellStyle();
  6. keyStyle.setFont(bold);
  7. return keyStyle;
  8. }

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

  1. private static HSSFFont createCustomFont(short colorIndex, Byte underlineWeight) {
  2. HSSFFont font = wb1.createFont();
  3. font.setFontName(HSSFFont.FONT_ARIAL);
  4. font.setFontHeightInPoints((short) 10);
  5. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  6. font.setColor(colorIndex);
  7. font.setUnderline(underlineWeight);
  8. return font;
  9. }

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

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

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

  1. private static HSSFCellStyle createCommentStyle(HSSFWorkbook wb) {
  2. HSSFFont commentFont = wb.createFont();
  3. commentFont.setColor(HSSFColor.GREEN.index);
  4. commentFont.setItalic(true);
  5. commentFont.setFontHeightInPoints((short)12);
  6. HSSFCellStyle commentStyle = wb.createCellStyle();
  7. commentStyle.setFont(commentFont);
  8. return commentStyle;
  9. }

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

  1. HSSFFont boldFont = wb.createFont();
  2. boldFont.setFontHeightInPoints((short)22);
  3. boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); //Setting Bold font
  4. HSSFCellStyle boldStyle = wb.createCellStyle();
  5. boldStyle.setFont(boldFont); //Attaching the font to the Style
  6. HSSFRow row = sheet1.createRow((short)1);
  7. HSSFCell cell = row.createCell((short)0);
  8. cell.setCellValue("This quick brown fox");
  9. cell.setCellStyle(boldStyle); //Applying Style to the Cell.

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

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

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

  1. private static HSSFCellStyle createPlurarStyle(HSSFWorkbook wb) {
  2. HSSFFont commentFont = wb.createFont();
  3. commentFont.setColor(HSSFColor.GREY_50_PERCENT.index);
  4. commentFont.setItalic(true);
  5. commentFont.setFontHeightInPoints((short)12);
  6. HSSFCellStyle commentStyle = wb.createCellStyle();
  7. commentStyle.setFont(commentFont);
  8. return commentStyle;
  9. }

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

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

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

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

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

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

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

  1. font.setFontName("宋体");
  2. if(position_title.equals(position)){
  3. font.setFontHeightInPoints((short)11);
  4. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  5. }else{
  6. font.setFontHeightInPoints((short)10);

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

  1. //////////////////////Excel Header Style/////////////////////////
  2. HSSFCellStyle headerlabelcs = wb.createCellStyle();
  3. headerlabelcs.setFillForegroundColor(HSSFColor.PALE_BLUE.index);
  4. headerlabelcs.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  5. headerlabelcs.setBorderLeft((short)1);
  6. headerlabelcs.setBorderRight((short)1);
  7. HSSFFont headerlabelfont = wb.createFont();
  8. headerlabelfont.setFontHeightInPoints((short)12);
  9. headerlabelfont.setFontName("Calibri");
  10. headerlabelfont.setColor(HSSFColor.BLACK.index);
  11. headerlabelfont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  12. headerlabelcs.setFont(headerlabelfont);
  13. //////////////////////Excel Header Style/////////////////////////

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

  1. public static void main(String[] args) throws IOException {
  2. try (HSSFWorkbook wb = new HSSFWorkbook()) {
  3. HSSFSheet sheet = wb.createSheet("new sheet");
  4. // Create a row and put some cells in it. Rows are 0 based.
  5. HSSFRow row = sheet.createRow(1);
  6. // Create a new font and alter it.
  7. HSSFFont font = wb.createFont();
  8. font.setFontHeightInPoints((short) 24);
  9. font.setFontName("Courier New");
  10. font.setItalic(true);
  11. font.setStrikeout(true);
  12. // Fonts are set into a style so create a new one to use.
  13. HSSFCellStyle style = wb.createCellStyle();
  14. style.setFont(font);
  15. // Create a cell and put a value in it.
  16. HSSFCell cell = row.createCell(1);
  17. cell.setCellValue("This is a test of fonts");
  18. cell.setCellStyle(style);
  19. // Write the output to a file
  20. try (FileOutputStream fileOut = new FileOutputStream("workbook.xls")) {
  21. wb.write(fileOut);
  22. }
  23. }
  24. }
  25. }

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

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

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

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

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

  1. /**
  2. * @see org.displaytag.render.TableWriterTemplate#writeCaption(org.displaytag.model.TableModel)
  3. */
  4. protected void writeCaption(TableModel model) throws Exception
  5. {
  6. HSSFCellStyle style = this.wb.createCellStyle();
  7. HSSFFont bold = this.wb.createFont();
  8. bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  9. bold.setFontHeightInPoints((short) 14);
  10. style.setFont(bold);
  11. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  12. this.colNum = 0;
  13. this.currentRow = this.sheet.createRow(this.rowNum++);
  14. this.currentCell = this.currentRow.createCell(this.colNum);
  15. this.currentCell.setCellStyle(style);
  16. String caption = model.getCaption();
  17. this.currentCell.setCellValue(new HSSFRichTextString(caption));
  18. this.rowSpanTable(model);
  19. }

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

  1. /**
  2. * @see org.displaytag.render.TableWriterTemplate#writeCaption(org.displaytag.model.TableModel)
  3. */
  4. @Override
  5. protected void writeCaption(TableModel model) throws Exception
  6. {
  7. HSSFCellStyle style = this.wb.createCellStyle();
  8. HSSFFont bold = this.wb.createFont();
  9. bold.setBold(true);
  10. bold.setFontHeightInPoints((short) 14);
  11. style.setFont(bold);
  12. style.setAlignment(HorizontalAlignment.CENTER);
  13. this.colNum = 0;
  14. this.currentRow = this.sheet.createRow(this.sheetRowNum++);
  15. this.currentCell = this.currentRow.createCell(this.colNum);
  16. this.currentCell.setCellStyle(style);
  17. String caption = model.getCaption();
  18. this.currentCell.setCellValue(new HSSFRichTextString(caption));
  19. this.rowSpanTable(model);
  20. }

相关文章