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

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

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

HSSFWorkbook.createFont介绍

[英]create a new Font and add it to the workbook's font table
[中]创建新字体并将其添加到工作簿的字体表中

代码示例

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

  1. HSSFFont boldFont = workbook.createFont();
  2. boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

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

  1. style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  2. HSSFFont font = wb.createFont();
  3. font.setColor(HSSFColor.RED.index);
  4. style.setFont(font);

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

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

代码示例来源:origin: qcadoo/mes

  1. FontsContainer(HSSFWorkbook workbook) {
  2. boldFont = workbook.createFont();
  3. boldFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
  4. }
  5. }

代码示例来源:origin: qcadoo/mes

  1. FontsContainer(HSSFWorkbook workbook) {
  2. headerFont = workbook.createFont();
  3. headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
  4. }
  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: 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: 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: 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: 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: stackoverflow.com

  1. HSSFWorkbook wb = new HSSFWorkbook();
  2. HSSFSheet sheet = wb.createSheet("New sheet");
  3. HSSFFont font = wb.createFont();
  4. font.setFontName("Arial Unicode MS");
  5. HSSFCellStyle style = wb.createCellStyle();
  6. style.setFont(font);
  7. HSSFRow row = sheet.createRow((short) 0);
  8. HSSFCell cell = row.createCell((short) 0);
  9. cell.setEncoding(HSSFCell.ENCODING_UTF_16);
  10. cell.setCellStyle(style);
  11. cell.setCellValue("\u53f8");

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

  1. HSSFFont font=wb.createFont();
  2. font.setFontHeight((short)(cellStyle.getFontSize()*20));
  3. Boolean bold=cellStyle.getBold();

代码示例来源: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: 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: org.motechproject/motech-bulk-export-import

  1. public HSSFCellStyle style() {
  2. Font font = worksheet.getWorkbook().createFont();
  3. font.setBoldweight(Font.BOLDWEIGHT_BOLD);
  4. font.setFontHeight((short) TITLE_FONT_HEIGHT);
  5. HSSFCellStyle cellStyle = worksheet.getWorkbook().createCellStyle();
  6. cellStyle.setAlignment(alignment);
  7. cellStyle.setWrapText(true);
  8. cellStyle.setFont(font);
  9. return cellStyle;
  10. }
  11. }

代码示例来源:origin: org.metaeffekt.core/ae-inventory-processor

  1. private HSSFCellStyle createHeaderStyle(HSSFWorkbook myWorkBook) {
  2. Font headerFont = myWorkBook.createFont();
  3. headerFont.setColor(Font.COLOR_NORMAL);
  4. HSSFPalette palette = myWorkBook.getCustomPalette();
  5. HSSFColor headerColor = palette.findSimilarColor((byte) 149, (byte) 179, (byte) 215);
  6. HSSFCellStyle headerStyle = myWorkBook.createCellStyle();
  7. headerStyle.setFillForegroundColor(headerColor.getIndex());
  8. headerStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
  9. headerStyle.setFont(headerFont);
  10. headerStyle.setWrapText(true);
  11. return headerStyle;
  12. }

相关文章

HSSFWorkbook类方法