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

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

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

HSSFFont.setBold介绍

[英]sets the font to be bold or not
[中]将字体设置为粗体或非粗体

代码示例

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

  1. private HSSFFont matchFont( Font matchFont )
  2. {
  3. HSSFColor hssfColor = workbook.getCustomPalette()
  4. .findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
  5. if (hssfColor == null)
  6. hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
  7. boolean bold = (matchFont.getStyle() & Font.BOLD) != 0;
  8. boolean italic = (matchFont.getStyle() & Font.ITALIC) != 0;
  9. HSSFFont hssfFont = workbook.findFont(bold,
  10. hssfColor.getIndex(),
  11. (short)(matchFont.getSize() * 20),
  12. matchFont.getName(),
  13. italic,
  14. false,
  15. (short)0,
  16. (byte)0);
  17. if (hssfFont == null)
  18. {
  19. hssfFont = workbook.createFont();
  20. hssfFont.setBold(bold);
  21. hssfFont.setColor(hssfColor.getIndex());
  22. hssfFont.setFontHeight((short)(matchFont.getSize() * 20));
  23. hssfFont.setFontName(matchFont.getName());
  24. hssfFont.setItalic(italic);
  25. hssfFont.setStrikeout(false);
  26. hssfFont.setTypeOffset((short) 0);
  27. hssfFont.setUnderline((byte) 0);
  28. }
  29. return hssfFont;
  30. }

代码示例来源:origin: com.haulmont.cuba/cuba-gui

  1. protected void createFonts() {
  2. stdFont = wb.createFont();
  3. boldFont = wb.createFont();
  4. boldFont.setBold(true);
  5. }

代码示例来源:origin: com.haulmont.charts/charts-web

  1. protected void createCellStyle() {
  2. HSSFFont boldFont = wb.createFont();
  3. boldFont.setBold(true);
  4. boldStyle = wb.createCellStyle();
  5. boldStyle.setFont(boldFont);
  6. }

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

  1. private HSSFFont matchFont( Font matchFont )
  2. {
  3. HSSFColor hssfColor = workbook.getCustomPalette()
  4. .findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
  5. if (hssfColor == null)
  6. hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
  7. boolean bold = (matchFont.getStyle() & Font.BOLD) != 0;
  8. boolean italic = (matchFont.getStyle() & Font.ITALIC) != 0;
  9. HSSFFont hssfFont = workbook.findFont(bold,
  10. hssfColor.getIndex(),
  11. (short)(matchFont.getSize() * 20),
  12. matchFont.getName(),
  13. italic,
  14. false,
  15. (short)0,
  16. (byte)0);
  17. if (hssfFont == null)
  18. {
  19. hssfFont = workbook.createFont();
  20. hssfFont.setBold(bold);
  21. hssfFont.setColor(hssfColor.getIndex());
  22. hssfFont.setFontHeight((short)(matchFont.getSize() * 20));
  23. hssfFont.setFontName(matchFont.getName());
  24. hssfFont.setItalic(italic);
  25. hssfFont.setStrikeout(false);
  26. hssfFont.setTypeOffset((short) 0);
  27. hssfFont.setUnderline((byte) 0);
  28. }
  29. return hssfFont;
  30. }

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

  1. font.setFontHeightInPoints((short)12);
  2. font.setFontName("Arial");
  3. font.setBold(true);

代码示例来源:origin: youseries/ureport

  1. font.setBold(bold);

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

  1. InputStream inp;
  2. HSSFWorkbook wb = null;
  3. HSSFSheet sheet = null;
  4. HSSFRow hssf_DataRow;
  5. HSSFCell cell = null;
  6. inp = new FileInputStream(FileName);
  7. wb = new HSSFWorkbook(inp);
  8. sheet = wb.getSheetAt(1);
  9. hssf_DataRow = sheet.createRow((short) 1);
  10. cell = hssf_DataRow.createCell(1);
  11. HSSFFont font = (HSSFFont) sheet.getWorkbook().createFont();
  12. HSSFCellStyle style = (HSSFCellStyle) cell.getCellStyle();
  13. font.setBold(true);
  14. style.setFont(font);
  15. style.setFillPattern(CellStyle.SOLID_FOREGROUND);
  16. style.setFillForegroundColor(new HSSFColor.BLUE().getIndex());
  17. cell.setCellStyle(style);

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

  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. HSSFFont bold = this.wb.createFont();
  9. bold.setBold(true);
  10. style.setBorderBottom(BorderStyle.THIN);
  11. style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
  12. style.setFont(bold);
  13. return style;
  14. }

代码示例来源: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: com.github.hazendaz/displaytag

  1. /**
  2. * Templated method that is called for all header cells.
  3. *
  4. * @param wb the wb
  5. * @param headerCell the header cell
  6. * @return the HSSF cell style
  7. */
  8. public HSSFCellStyle createHeaderStyle(HSSFWorkbook wb, HeaderCell headerCell)
  9. {
  10. HSSFCellStyle headerStyle = getNewCellStyle();
  11. headerStyle.setFillPattern(FillPatternType.FINE_DOTS);
  12. headerStyle.setFillBackgroundColor(HSSFColorPredefined.BLUE_GREY.getIndex());
  13. HSSFFont bold = wb.createFont();
  14. bold.setBold(true);
  15. bold.setColor(HSSFColorPredefined.WHITE.getIndex());
  16. headerStyle.setFont(bold);
  17. return headerStyle;
  18. }

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

  1. boldFont.setBold(true);

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

代码示例来源:origin: org.tentackle/tentackle-swing

  1. HSSFRow row = sheet.createRow(srow);
  2. HSSFFont font = wb.createFont();
  3. font.setBold(true);
  4. HSSFCellStyle cs = wb.createCellStyle();
  5. cs.setAlignment(HorizontalAlignment.CENTER);
  6. HSSFFont font = wb.createFont();
  7. font.setItalic(true);
  8. font.setBold(true);
  9. HSSFCellStyle cs = wb.createCellStyle();
  10. cs.setAlignment(HorizontalAlignment.CENTER);

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

  1. f.setBold(true);
  2. f2.setFontHeightInPoints((short) 10);
  3. f2.setColor((short) 0xf);
  4. f2.setBold(true);
  5. cs.setFont(f);
  6. cs.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));

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

  1. f.setBold(true);
  2. f2.setBold(true);

代码示例来源:origin: cuba-platform/yarg

  1. newFont.setStrikeout(cellFont.getStrikeout());
  2. newFont.setTypeOffset(cellFont.getTypeOffset());
  3. newFont.setBold(cellFont.getBold());
  4. newFont.setCharSet(cellFont.getCharSet());
  5. newFont.setColor(cellFont.getColor());

代码示例来源:origin: com.bstek.ureport/ureport2-core

  1. font.setBold(bold);

相关文章