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

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

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

HSSFFont.setBoldweight介绍

[英]set the boldness to use
[中]设置要使用的粗体

代码示例

代码示例来源:origin: rakam-io/rakam

  1. boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

代码示例来源: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: 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: 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: com.dexcoder/dexcoder-commons

  1. /**
  2. * 生成sheet列标题行
  3. *
  4. * @param workbook 工作薄对象
  5. * @param sheet sheet对象
  6. * @param excelSheet the excel sheet
  7. */
  8. public void createTitle(HSSFWorkbook workbook, HSSFSheet sheet, ExcelSheet excelSheet) {
  9. // 创建表格标题行
  10. HSSFRow row = sheet.createRow(0);
  11. List<String> rowTitles = excelSheet.getRowTitles();
  12. for (int i = 0; i < rowTitles.size(); i++) {
  13. HSSFCell cell = row.createCell(i);
  14. HSSFRichTextString text = new HSSFRichTextString(rowTitles.get(i));
  15. HSSFFont font = workbook.createFont();
  16. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  17. text.applyFont(font);
  18. cell.setCellValue(text);
  19. }
  20. }

代码示例来源:origin: selfly/dexcoder-assistant

  1. /**
  2. * 生成sheet列标题行
  3. *
  4. * @param workbook 工作薄对象
  5. * @param sheet sheet对象
  6. * @param excelSheet the excel sheet
  7. */
  8. public void createTitle(HSSFWorkbook workbook, HSSFSheet sheet, ExcelSheet excelSheet) {
  9. // 创建表格标题行
  10. HSSFRow row = sheet.createRow(0);
  11. List<String> rowTitles = excelSheet.getRowTitles();
  12. for (int i = 0; i < rowTitles.size(); i++) {
  13. HSSFCell cell = row.createCell(i);
  14. HSSFRichTextString text = new HSSFRichTextString(rowTitles.get(i));
  15. HSSFFont font = workbook.createFont();
  16. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  17. text.applyFont(font);
  18. cell.setCellValue(text);
  19. }
  20. }

代码示例来源:origin: org.sakaiproject.assignment/sakai-assignment-impl

  1. private HSSFCellStyle createHeaderStyle(){
  2. //TO-DO read style information from sakai.properties
  3. HSSFFont font = gradesWorkbook.createFont();
  4. font.setFontName(HSSFFont.FONT_ARIAL);
  5. font.setColor(IndexedColors.PLUM.getIndex());
  6. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  7. HSSFCellStyle cellStyle = gradesWorkbook.createCellStyle();
  8. cellStyle.setFont(font);
  9. return cellStyle;
  10. }

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

  1. /**
  2. * Obtain the style used to render a header or footer.
  3. * @return The style used to render a header or footer.
  4. */
  5. private HSSFCellStyle getHeaderFooterStyle()
  6. {
  7. HSSFCellStyle style = this.wb.createCellStyle();
  8. style.setFillPattern(HSSFCellStyle.FINE_DOTS);
  9. style.setFillBackgroundColor(HSSFColor.BLUE_GREY.index);
  10. HSSFFont bold = this.wb.createFont();
  11. bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  12. bold.setColor(HSSFColor.WHITE.index);
  13. style.setFont(bold);
  14. return style;
  15. }

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

  1. private static HSSFCellStyle createTilteStyle(HSSFWorkbook wb) {
  2. HSSFFont bold = wb.createFont();
  3. bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  4. HSSFCellStyle style = wb.createCellStyle();
  5. style.setFont(bold);
  6. style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
  7. style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  8. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  9. style.setWrapText(true);
  10. return style;
  11. }

代码示例来源:origin: com.github.mg365/mg-common

  1. /**
  2. * 设置Excel表头字体颜色
  3. *
  4. * @param wb Excel文件
  5. * @return: 字体对象
  6. */
  7. private HSSFCellStyle createRedFont(HSSFWorkbook wb) {
  8. HSSFCellStyle style = wb.createCellStyle();
  9. HSSFFont font = wb.createFont();
  10. font.setColor(HSSFColor.BLACK.index);
  11. font.setBoldweight(Font.BOLDWEIGHT_BOLD);
  12. style.setFont(font);
  13. style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
  14. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  15. return style;
  16. }

代码示例来源: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: 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: org.seasar.tuigwaa/tuigwaa-ext

  1. private void createDefaultHeaderCellStyle() {
  2. headerCellStyle = workbook.createCellStyle();
  3. HSSFFont font = workbook.createFont();
  4. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  5. font.setColor(HSSFColor.WHITE.index);
  6. headerCellStyle.setFont(font);
  7. headerCellStyle
  8. .setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index);
  9. headerCellStyle.setFillPattern(HSSFCellStyle.FINE_DOTS);
  10. headerCellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
  11. headerCellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  12. }

代码示例来源: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: Impetus/jumbune

  1. /**
  2. * Sets header style
  3. * @param worksheet the worksheet
  4. * @param fontName font name
  5. * @param fontColor font color
  6. * @param fontBoldweight font weight
  7. */
  8. public static void setHeaderStyle(Worksheet worksheet, String fontName,
  9. short fontColor, short fontBoldweight) {
  10. HSSFWorkbook workbook = worksheet.getWorkbook();
  11. HSSFFont font = workbook.createFont();
  12. font.setFontName(fontName);
  13. font.setColor(fontColor);
  14. font.setBoldweight(fontBoldweight);
  15. HSSFCellStyle cellStyle = workbook.createCellStyle();
  16. cellStyle.setFont(font);
  17. worksheet.setCellStyle(cellStyle);
  18. }

代码示例来源:origin: riotfamily/riot

  1. private void createHeadings(String... labels) {
  2. HSSFCellStyle style = wb.createCellStyle();
  3. HSSFFont font = wb.createFont();
  4. font.setFontName("Trebuchet MS");
  5. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  6. style.setFont(font);
  7. HSSFRow row = sheet.createRow(0);
  8. int col = 0;
  9. for (String label : labels) {
  10. HSSFCell cell = row.createCell(col++);
  11. cell.setCellStyle(style);
  12. cell.setCellValue(new HSSFRichTextString(label));
  13. }
  14. }

代码示例来源:origin: riotfamily/riot

  1. private void createHeadings(String... labels) {
  2. HSSFCellStyle style = wb.createCellStyle();
  3. HSSFFont font = wb.createFont();
  4. font.setFontName("Trebuchet MS");
  5. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  6. style.setFont(font);
  7. HSSFRow row = sheet.createRow(0);
  8. int col = 0;
  9. for (String label : labels) {
  10. HSSFCell cell = row.createCell(col++);
  11. cell.setCellStyle(style);
  12. cell.setCellValue(new HSSFRichTextString(label));
  13. }
  14. }

代码示例来源:origin: com.jalalkiswani/jk-util

  1. /**
  2. */
  3. protected void createColumnHeaders() {
  4. final HSSFRow headersRow = this.sheet.createRow(0);
  5. final HSSFFont font = this.workbook.createFont();
  6. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  7. final HSSFCellStyle style = this.workbook.createCellStyle();
  8. style.setFont(font);
  9. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  10. int counter = 1;
  11. for (int i = 0; i < this.model.getColumnCount(); i++) {
  12. final HSSFCell cell = headersRow.createCell(counter++);
  13. // cell.setEncoding(HSSFCell.ENCODING_UTF_16);
  14. cell.setCellValue(this.model.getColumnName(i));
  15. cell.setCellStyle(style);
  16. }
  17. }

代码示例来源: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. }

相关文章