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

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

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

HSSFFont.setItalic介绍

[英]set whether to use italics or not
[中]设置是否使用斜体

代码示例

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

private HSSFFont matchFont( Font matchFont )
{
  HSSFColor hssfColor = workbook.getCustomPalette()
      .findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
  if (hssfColor == null)
    hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
  boolean bold = (matchFont.getStyle() & Font.BOLD) != 0;
  boolean italic = (matchFont.getStyle() & Font.ITALIC) != 0;
  HSSFFont hssfFont = workbook.findFont(bold,
        hssfColor.getIndex(),
        (short)(matchFont.getSize() * 20),
        matchFont.getName(),
        italic,
        false,
        (short)0,
        (byte)0);
  if (hssfFont == null)
  {
    hssfFont = workbook.createFont();
    hssfFont.setBold(bold);
    hssfFont.setColor(hssfColor.getIndex());
    hssfFont.setFontHeight((short)(matchFont.getSize() * 20));
    hssfFont.setFontName(matchFont.getName());
    hssfFont.setItalic(italic);
    hssfFont.setStrikeout(false);
    hssfFont.setTypeOffset((short) 0);
    hssfFont.setUnderline((byte) 0);
  }
  return hssfFont;
}

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

HSSFFont font = wb.createFont();
font.setItalic(true);
font.setUnderline(HSSFFont.U_DOUBLE);
HSSFRichTextString string = new HSSFRichTextString("Woo!!!");
string.applyFont(2,5,font);
textbox.setString(string );

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

HSSFFont font = wb.createFont();
font.setItalic(true);
font.setUnderline(HSSFFont.U_DOUBLE);
HSSFRichTextString string = new HSSFRichTextString("Woo!!!");
string.applyFont(2,5,font);
textbox.setString(string );

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

font.setItalic(true);
style = workbook.createCellStyle();
style.setFont(font);

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

private HSSFFont matchFont( Font font )
{
  HSSFColor hssfColor = workbook.getCustomPalette()
      .findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
  if (hssfColor == null)
    hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
  boolean bold = (font.getStyle() & Font.BOLD) != 0;
  boolean italic = (font.getStyle() & Font.ITALIC) != 0;
  HSSFFont hssfFont = workbook.findFont(bold ? HSSFFont.BOLDWEIGHT_BOLD : 0,
        hssfColor.getIndex(),
        (short)(font.getSize() * 20),
        font.getName(),
        italic,
        false,
        (short)0,
        (byte)0);
  if (hssfFont == null)
  {
    hssfFont = workbook.createFont();
    hssfFont.setBoldweight(bold ? HSSFFont.BOLDWEIGHT_BOLD : 0);
    hssfFont.setColor(hssfColor.getIndex());
    hssfFont.setFontHeight((short)(font.getSize() * 20));
    hssfFont.setFontName(font.getName());
    hssfFont.setItalic(italic);
    hssfFont.setStrikeout(false);
    hssfFont.setTypeOffset((short) 0);
    hssfFont.setUnderline((byte) 0);
  }
  return hssfFont;
}

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

private HSSFFont matchFont( Font matchFont )
{
  HSSFColor hssfColor = workbook.getCustomPalette()
      .findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
  if (hssfColor == null)
    hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
  boolean bold = (matchFont.getStyle() & Font.BOLD) != 0;
  boolean italic = (matchFont.getStyle() & Font.ITALIC) != 0;
  HSSFFont hssfFont = workbook.findFont(bold,
        hssfColor.getIndex(),
        (short)(matchFont.getSize() * 20),
        matchFont.getName(),
        italic,
        false,
        (short)0,
        (byte)0);
  if (hssfFont == null)
  {
    hssfFont = workbook.createFont();
    hssfFont.setBold(bold);
    hssfFont.setColor(hssfColor.getIndex());
    hssfFont.setFontHeight((short)(matchFont.getSize() * 20));
    hssfFont.setFontName(matchFont.getName());
    hssfFont.setItalic(italic);
    hssfFont.setStrikeout(false);
    hssfFont.setTypeOffset((short) 0);
    hssfFont.setUnderline((byte) 0);
  }
  return hssfFont;
}

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

private HSSFFont matchFont( Font font )
{
  HSSFColor hssfColor = workbook.getCustomPalette()
      .findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
  if (hssfColor == null)
    hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
  boolean bold = (font.getStyle() & Font.BOLD) != 0;
  boolean italic = (font.getStyle() & Font.ITALIC) != 0;
  HSSFFont hssfFont = workbook.findFont(bold ? HSSFFont.BOLDWEIGHT_BOLD : 0,
        hssfColor.getIndex(),
        (short)(font.getSize() * 20),
        font.getName(),
        italic,
        false,
        (short)0,
        (byte)0);
  if (hssfFont == null)
  {
    hssfFont = workbook.createFont();
    hssfFont.setBoldweight(bold ? HSSFFont.BOLDWEIGHT_BOLD : 0);
    hssfFont.setColor(hssfColor.getIndex());
    hssfFont.setFontHeight((short)(font.getSize() * 20));
    hssfFont.setFontName(font.getName());
    hssfFont.setItalic(italic);
    hssfFont.setStrikeout(false);
    hssfFont.setTypeOffset((short) 0);
    hssfFont.setUnderline((byte) 0);
  }
  return hssfFont;
}

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

private static HSSFCellStyle createCommentStyle(HSSFWorkbook wb) {
  HSSFFont commentFont = wb.createFont();
  commentFont.setColor(HSSFColor.GREEN.index);
  commentFont.setItalic(true);
  commentFont.setFontHeightInPoints((short)12);
  HSSFCellStyle commentStyle = wb.createCellStyle();
  commentStyle.setFont(commentFont);
  return commentStyle;
}

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

private static HSSFCellStyle createPlurarStyle(HSSFWorkbook wb) {
  HSSFFont commentFont = wb.createFont();
  commentFont.setColor(HSSFColor.GREY_50_PERCENT.index);
  commentFont.setItalic(true);
  commentFont.setFontHeightInPoints((short)12);
  HSSFCellStyle commentStyle = wb.createCellStyle();
  commentStyle.setFont(commentFont);
  return commentStyle;
}

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

font.setItalic(italic);

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

public static void main(String[] args) throws IOException {
    try (HSSFWorkbook wb = new HSSFWorkbook()) {
      HSSFSheet sheet = wb.createSheet("new sheet");

      // Create a row and put some cells in it. Rows are 0 based.
      HSSFRow row = sheet.createRow(1);

      // Create a new font and alter it.
      HSSFFont font = wb.createFont();
      font.setFontHeightInPoints((short) 24);
      font.setFontName("Courier New");
      font.setItalic(true);
      font.setStrikeout(true);

      // Fonts are set into a style so create a new one to use.
      HSSFCellStyle style = wb.createCellStyle();
      style.setFont(font);

      // Create a cell and put a value in it.
      HSSFCell cell = row.createCell(1);
      cell.setCellValue("This is a test of fonts");
      cell.setCellStyle(style);

      // Write the output to a file
      try (FileOutputStream fileOut = new FileOutputStream("workbook.xls")) {
        wb.write(fileOut);
      }
    }
  }
}

代码示例来源:origin: jasperreports/jasperreports

cellFont.setItalic(true);
cellFont.setItalic(true);

代码示例来源:origin: org.onap.portal.sdk/epsdk-analytics

fontDefault.setFontHeight((short) (font_size / 0.05));
fontDefault.setFontName("Tahoma");
fontDefault.setItalic(true);

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

fontNew.setFontName(fontOld.getFontName());
fontNew.setFontHeight(fontOld.getFontHeight());
fontNew.setItalic(fontOld.getItalic());
fontNew.setStrikeout(fontOld.getStrikeout());
fontNew.setTypeOffset(fontOld.getTypeOffset());

代码示例来源:origin: org.onap.portal.sdk/epsdk-analytics

cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
if (fmt.isItalic())
  cellFont.setItalic(true);
if (fmt.isUnderline())
  cellFont.setUnderline(HSSFFont.U_SINGLE);

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

font.setItalic(true);
font.setBold(true);
HSSFCellStyle cs = wb.createCellStyle();

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

private static void drawSheet4( HSSFSheet sheet4, HSSFWorkbook wb )
{
  // Create the drawing patriarch.  This is the top level container for
  // all shapes. This will clear out any existing shapes for that sheet.
  HSSFPatriarch patriarch = sheet4.createDrawingPatriarch();
  // Create a couple of textboxes
  HSSFTextbox textbox1 = patriarch.createTextbox(
      new HSSFClientAnchor(0,0,0,0,(short)1,1,(short)2,2));
  textbox1.setString(new HSSFRichTextString("This is a test") );
  HSSFTextbox textbox2 = patriarch.createTextbox(
      new HSSFClientAnchor(0,0,900,100,(short)3,3,(short)3,4));
  textbox2.setString(new HSSFRichTextString("Woo") );
  textbox2.setFillColor(200,0,0);
  textbox2.setLineStyle(HSSFSimpleShape.LINESTYLE_DOTGEL);
  // Create third one with some fancy font styling.
  HSSFTextbox textbox3 = patriarch.createTextbox(
      new HSSFClientAnchor(0,0,900,100,(short)4,4,(short)5,4+1));
  HSSFFont font = wb.createFont();
  font.setItalic(true);
  font.setUnderline(HSSFFont.U_DOUBLE);
  HSSFRichTextString string = new HSSFRichTextString("Woo!!!");
  string.applyFont(2,5,font);
  textbox3.setString(string );
  textbox3.setFillColor(0x08000030);
  textbox3.setLineStyle(HSSFSimpleShape.LINESTYLE_NONE);  // no line around the textbox.
  textbox3.setNoFill(true);    // make it transparent
}

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

newFont.setItalic(cellFont.getItalic());
newFont.setStrikeout(cellFont.getStrikeout());
newFont.setTypeOffset(cellFont.getTypeOffset());

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

newFont.setItalic(cellFont.getItalic());
newFont.setStrikeout(cellFont.getStrikeout());
newFont.setTypeOffset(cellFont.getTypeOffset());

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

font.setItalic(italic);

相关文章