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

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

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

HSSFFont.getColor介绍

[英]get the color for the font
[中]获取字体的颜色

代码示例

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

  1. /**
  2. * get the color value for the font
  3. */
  4. public HSSFColor getHSSFColor(HSSFWorkbook wb)
  5. {
  6. HSSFPalette pallette = wb.getCustomPalette();
  7. return pallette.getColor( getColor() );
  8. }

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

  1. /**
  2. * Finds a font that matches the one with the supplied attributes
  3. */
  4. @Override
  5. public HSSFFont findFont(boolean bold, short color, short fontHeight,
  6. String name, boolean italic, boolean strikeout,
  7. short typeOffset, byte underline)
  8. {
  9. int numberOfFonts = getNumberOfFontsAsInt();
  10. for (int i = 0; i <= numberOfFonts; i++) {
  11. // Remember - there is no 4!
  12. if(i == 4) {
  13. continue;
  14. }
  15. HSSFFont hssfFont = getFontAt(i);
  16. if (hssfFont.getBold() == bold
  17. && hssfFont.getColor() == color
  18. && hssfFont.getFontHeight() == fontHeight
  19. && hssfFont.getFontName().equals(name)
  20. && hssfFont.getItalic() == italic
  21. && hssfFont.getStrikeout() == strikeout
  22. && hssfFont.getTypeOffset() == typeOffset
  23. && hssfFont.getUnderline() == underline)
  24. {
  25. return hssfFont;
  26. }
  27. }
  28. return null;
  29. }

代码示例来源:origin: com.haulmont.thirdparty/poi

  1. /**
  2. * get the color value for the font
  3. */
  4. public HSSFColor getHSSFColor(HSSFWorkbook wb)
  5. {
  6. HSSFPalette pallette = wb.getCustomPalette();
  7. return pallette.getColor( getColor() );
  8. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. /**
  2. * get the color value for the font
  3. */
  4. public HSSFColor getHSSFColor(HSSFWorkbook wb)
  5. {
  6. HSSFPalette pallette = wb.getCustomPalette();
  7. return pallette.getColor( getColor() );
  8. }

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

  1. /**
  2. * get the color value for the font
  3. */
  4. public HSSFColor getHSSFColor(HSSFWorkbook wb)
  5. {
  6. HSSFPalette pallette = wb.getCustomPalette();
  7. return pallette.getColor( getColor() );
  8. }

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

  1. void buildStyle_font( HSSFWorkbook workbook, StringBuilder style,
  2. HSSFFont font ) {
  3. if ( font.getBold() )
  4. {
  5. style.append( "font-weight:bold;" );
  6. }
  7. final HSSFColor fontColor = workbook.getCustomPalette().getColor(
  8. font.getColor() );
  9. if ( fontColor != null )
  10. style.append("color: ").append(ExcelToHtmlUtils.getColor(fontColor)).append("; ");
  11. if ( font.getFontHeightInPoints() != 0 )
  12. style.append("font-size:").append(font.getFontHeightInPoints()).append("pt;");
  13. if ( font.getItalic() )
  14. {
  15. style.append( "font-style:italic;" );
  16. }
  17. }

代码示例来源:origin: zhangdaiscott/jeasypoi

  1. public void colorStyles(CellStyle style, Formatter out) {
  2. HSSFCellStyle cs = (HSSFCellStyle) style;
  3. out.format(" /* fill pattern = %d */%n", cs.getFillPattern());
  4. styleColor(out, "background-color", cs.getFillForegroundColor());
  5. styleColor(out, "color", colors.getColor(cs.getFont(wb).getColor()));
  6. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. void buildStyle_font( HSSFWorkbook workbook, StringBuilder style,
  2. HSSFFont font )
  3. {
  4. switch ( font.getBoldweight() )
  5. {
  6. case HSSFFont.BOLDWEIGHT_BOLD:
  7. style.append( "font-weight:bold;" );
  8. break;
  9. case HSSFFont.BOLDWEIGHT_NORMAL:
  10. // by default, not not increase HTML size
  11. // style.append( "font-weight: normal; " );
  12. break;
  13. }
  14. final HSSFColor fontColor = workbook.getCustomPalette().getColor(
  15. font.getColor() );
  16. if ( fontColor != null )
  17. style.append( "color: " + ExcelToHtmlUtils.getColor( fontColor )
  18. + "; " );
  19. if ( font.getFontHeightInPoints() != 0 )
  20. style.append( "font-size:" + font.getFontHeightInPoints() + "pt;" );
  21. if ( font.getItalic() )
  22. {
  23. style.append( "font-style:italic;" );
  24. }
  25. }

代码示例来源:origin: org.jeecg/easypoi-base

  1. public void colorStyles(CellStyle style, Formatter out) {
  2. HSSFCellStyle cs = (HSSFCellStyle) style;
  3. out.format(" /* fill pattern = %d */%n", cs.getFillPattern());
  4. styleColor(out, "background-color", cs.getFillForegroundColor());
  5. styleColor(out, "color", colors.getColor(cs.getFont(wb).getColor()));
  6. }

代码示例来源:origin: xiaolanglang/easypoi

  1. public void colorStyles(CellStyle style, Formatter out) {
  2. HSSFCellStyle cs = (HSSFCellStyle) style;
  3. out.format(" /* fill pattern = %d */%n", cs.getFillPattern());
  4. styleColor(out, "background-color", cs.getFillForegroundColor());
  5. styleColor(out, "color", colors.getColor(cs.getFont(wb).getColor()));
  6. }

代码示例来源:origin: cn.afterturn/easypoi-base

  1. @Override
  2. public void colorStyles(CellStyle style, Formatter out) {
  3. HSSFCellStyle cs = (HSSFCellStyle) style;
  4. if (cs.getFillPattern() != FillPatternType.NO_FILL) {
  5. out.format(" /* fill pattern = %s */%n", cs.getFillPattern());
  6. }
  7. styleColor(out, "background-color", cs.getFillForegroundColor());
  8. styleColor(out, "color", colors.getColor(cs.getFont(wb).getColor()));
  9. }

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

  1. protected void processCellStyleFont( HSSFWorkbook workbook,
  2. Element blockTarget, HSSFFont font )
  3. {
  4. Triplet triplet = new Triplet();
  5. triplet.fontName = font.getFontName();
  6. triplet.bold = font.getBold();
  7. triplet.italic = font.getItalic();
  8. getFontReplacer().update( triplet );
  9. setBlockProperties( blockTarget, triplet );
  10. final HSSFColor fontColor = workbook.getCustomPalette().getColor(
  11. font.getColor() );
  12. if ( fontColor != null )
  13. blockTarget.setAttribute( "color",
  14. ExcelToHtmlUtils.getColor( fontColor ) );
  15. if ( font.getFontHeightInPoints() != 0 )
  16. blockTarget.setAttribute( "font-size", font.getFontHeightInPoints()
  17. + "pt" );
  18. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. /**
  2. * Finds a font that matches the one with the supplied attributes
  3. */
  4. public HSSFFont findFont(short boldWeight, short color, short fontHeight,
  5. String name, boolean italic, boolean strikeout,
  6. short typeOffset, byte underline)
  7. {
  8. for (short i=0; i<=getNumberOfFonts(); i++) {
  9. // Remember - there is no 4!
  10. if(i == 4) continue;
  11. HSSFFont hssfFont = getFontAt(i);
  12. if (hssfFont.getBoldweight() == boldWeight
  13. && hssfFont.getColor() == color
  14. && hssfFont.getFontHeight() == fontHeight
  15. && hssfFont.getFontName().equals(name)
  16. && hssfFont.getItalic() == italic
  17. && hssfFont.getStrikeout() == strikeout
  18. && hssfFont.getTypeOffset() == typeOffset
  19. && hssfFont.getUnderline() == underline)
  20. {
  21. return hssfFont;
  22. }
  23. }
  24. return null;
  25. }

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

  1. /**
  2. * Finds a font that matches the one with the supplied attributes
  3. */
  4. @Override
  5. public HSSFFont findFont(boolean bold, short color, short fontHeight,
  6. String name, boolean italic, boolean strikeout,
  7. short typeOffset, byte underline)
  8. {
  9. int numberOfFonts = getNumberOfFontsAsInt();
  10. for (int i = 0; i <= numberOfFonts; i++) {
  11. // Remember - there is no 4!
  12. if(i == 4) {
  13. continue;
  14. }
  15. HSSFFont hssfFont = getFontAt(i);
  16. if (hssfFont.getBold() == bold
  17. && hssfFont.getColor() == color
  18. && hssfFont.getFontHeight() == fontHeight
  19. && hssfFont.getFontName().equals(name)
  20. && hssfFont.getItalic() == italic
  21. && hssfFont.getStrikeout() == strikeout
  22. && hssfFont.getTypeOffset() == typeOffset
  23. && hssfFont.getUnderline() == underline)
  24. {
  25. return hssfFont;
  26. }
  27. }
  28. return null;
  29. }

代码示例来源:origin: com.haulmont.thirdparty/poi

  1. /**
  2. * Finds a font that matches the one with the supplied attributes
  3. */
  4. public HSSFFont findFont(short boldWeight, short color, short fontHeight,
  5. String name, boolean italic, boolean strikeout,
  6. short typeOffset, byte underline)
  7. {
  8. for (short i=0; i<=getNumberOfFonts(); i++) {
  9. // Remember - there is no 4!
  10. if(i == 4) continue;
  11. HSSFFont hssfFont = getFontAt(i);
  12. if (hssfFont.getBoldweight() == boldWeight
  13. && hssfFont.getColor() == color
  14. && hssfFont.getFontHeight() == fontHeight
  15. && hssfFont.getFontName().equals(name)
  16. && hssfFont.getItalic() == italic
  17. && hssfFont.getStrikeout() == strikeout
  18. && hssfFont.getTypeOffset() == typeOffset
  19. && hssfFont.getUnderline() == underline)
  20. {
  21. return hssfFont;
  22. }
  23. }
  24. return null;
  25. }

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

  1. @Override
  2. public void colorStyles(CellStyle style, Formatter out) {
  3. HSSFCellStyle cs = (HSSFCellStyle) style;
  4. out.format(" /* fill pattern = %d */%n", cs.getFillPattern().getCode());
  5. styleColor(out, "background-color", cs.getFillForegroundColor());
  6. styleColor(out, "color", cs.getFont(wb).getColor());
  7. styleColor(out, "border-left-color", cs.getLeftBorderColor());
  8. styleColor(out, "border-right-color", cs.getRightBorderColor());
  9. styleColor(out, "border-top-color", cs.getTopBorderColor());
  10. styleColor(out, "border-bottom-color", cs.getBottomBorderColor());
  11. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. protected void processCellStyleFont( HSSFWorkbook workbook,
  2. Element blockTarget, HSSFFont font )
  3. {
  4. Triplet triplet = new Triplet();
  5. triplet.fontName = font.getFontName();
  6. switch ( font.getBoldweight() )
  7. {
  8. case HSSFFont.BOLDWEIGHT_BOLD:
  9. triplet.bold = true;
  10. break;
  11. case HSSFFont.BOLDWEIGHT_NORMAL:
  12. triplet.bold = false;
  13. break;
  14. }
  15. if ( font.getItalic() )
  16. {
  17. triplet.italic = true;
  18. }
  19. getFontReplacer().update( triplet );
  20. setBlockProperties( blockTarget, triplet );
  21. final HSSFColor fontColor = workbook.getCustomPalette().getColor(
  22. font.getColor() );
  23. if ( fontColor != null )
  24. blockTarget.setAttribute( "color",
  25. ExcelToHtmlUtils.getColor( fontColor ) );
  26. if ( font.getFontHeightInPoints() != 0 )
  27. blockTarget.setAttribute( "font-size", font.getFontHeightInPoints()
  28. + "pt" );
  29. }

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

  1. } else editor.setBackground(white);
  2. editor.setForeground(getAWTColor(f.getColor(), black));

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

  1. editor.setForeground(getAWTColor(f.getColor(), black));

代码示例来源:origin: com.haulmont.yarg/yarg

  1. newFont.setBoldweight(cellFont.getBoldweight());
  2. newFont.setCharSet(cellFont.getCharSet());
  3. newFont.setColor(cellFont.getColor());
  4. newFont.setUnderline(cellFont.getUnderline());
  5. newFont.setFontHeight(cellFont.getFontHeight());

相关文章