當前位置: 首頁>>代碼示例>>Java>>正文


Java Font.setItalic方法代碼示例

本文整理匯總了Java中org.apache.poi.ss.usermodel.Font.setItalic方法的典型用法代碼示例。如果您正苦於以下問題:Java Font.setItalic方法的具體用法?Java Font.setItalic怎麽用?Java Font.setItalic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.ss.usermodel.Font的用法示例。


在下文中一共展示了Font.setItalic方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setCellStyleFont

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
public void setCellStyleFont(Workbook workbook, CellStyle style, int i) {
	Font font = workbook.createFont();
	if (i == 0) {
		// 正常
	} else if (i == 4) {
		// 下劃線
		font.setUnderline(Font.U_SINGLE);
		style.setFont(font);
	} else if (i == 2) {
		// 傾斜
		font.setItalic(true);
		style.setFont(font);
	} else if (i == 1) {
		// 加粗
		font.setBold(true);
		style.setFont(font);
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:19,代碼來源:AbstractStyleBuilder.java

示例2: initFont

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
/**
 * 初始化字體樣式
 *
 * @param font
 * @param fontBean
 */
private void initFont(Font font, FontStyleBean fontBean) {
    font.setFontName(fontBean.getName());
    font.setFontHeightInPoints(fontBean.getSize());

    if (fontBean.getBoldWeight() != null) {
        font.setBoldweight(fontBean.getBoldWeight());
    }

    if (fontBean.getItalic() != null) {
        font.setItalic(fontBean.getItalic());
    }

    if (fontBean.getUnderLine() != null) {
        font.setUnderline(fontBean.getUnderLine());
    }

    if (fontBean.getColor() != null) {
        ColorBean cbean = fontBean.getColor();

        ((XSSFFont) font).setColor(new XSSFColor(new Color(cbean.getR(), cbean.getG(), cbean.getB())));
    }

}
 
開發者ID:cgfalcon,項目名稱:fluentexcel,代碼行數:30,代碼來源:XlsxRender.java

示例3: copyFont

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
/**
 * 複製字體
 * 
 * @author      ZhengWei(HY)
 * @createDate  2017-03-18
 * @version     v1.0
 *
 * @param i_FromFont  源字體
 * @param i_ToFont    目標字體
 */
public final static void copyFont(Font i_FromFont ,Font i_ToFont)
{
    i_ToFont.setBold(              i_FromFont.getBold());
    i_ToFont.setCharSet(           i_FromFont.getCharSet());
    i_ToFont.setColor(             i_FromFont.getColor());
    i_ToFont.setFontHeight(        i_FromFont.getFontHeight());
    i_ToFont.setFontHeightInPoints(i_FromFont.getFontHeightInPoints());
    i_ToFont.setFontName(          i_FromFont.getFontName());
    i_ToFont.setItalic(            i_FromFont.getItalic());
    i_ToFont.setStrikeout(         i_FromFont.getStrikeout());
    i_ToFont.setTypeOffset(        i_FromFont.getTypeOffset());
    i_ToFont.setUnderline(         i_FromFont.getUnderline());
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.report,代碼行數:24,代碼來源:ExcelHelp.java

示例4: configFont

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
private void configFont(Font font) {
    font.setBold(isBold());
    font.setItalic(isItalic());
    font.setStrikeout(isStrikeout());
    font.setUnderline(isUnderline() ? Font.U_SINGLE : Font.U_NONE);
    if (getFontSize() != null) {
        font.setFontHeightInPoints(fontSize.shortValue());
    }
    if (getFontColor() != null) {
        if (font instanceof XSSFFont) {
            ((XSSFFont)font).setColor(new XSSFColor(toRgbByte(fontColor)));
        } else {
            font.setColor(fontColor.getIndex());
        }
    }
}
 
開發者ID:tecsinapse,項目名稱:tecsinapse-data-io,代碼行數:17,代碼來源:TableCellStyle.java

示例5: setBold

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
/**
 * Set a bold font for the given cell with a given font size (in pt).
 * 
 * @param wb
 *            the workbook that contains the cell
 * @param cell
 *            the cell where the text is contained
 * @param size
 *            the size in pt of the text
 */
public static void setBold(Workbook wb, HSSFCell cell, short size) {
	Font font = wb.createFont();
	font.setFontHeightInPoints((short) size);
	font.setFontName("Arial");
	font.setColor(IndexedColors.BLACK.getIndex());
	font.setBold(true);
	font.setItalic(false);

	CellStyle style = wb.createCellStyle();
	style.setFont(font);
	cell.setCellStyle(style);
}
 
開發者ID:turnus,項目名稱:turnus,代碼行數:23,代碼來源:PoiUtils.java

示例6: createFont

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
@Override
public PoiFont createFont(com.dua3.utility.text.Font font) {
    Font poiFont = poiWorkbook.createFont();
    poiFont.setFontName(font.getFamily());
    poiFont.setFontHeight(((short) Math.round(20*font.getSizeInPoints())));
    poiFont.setColor(getPoiColor(font.getColor()).getIndex());
    poiFont.setBold(font.isBold());
    poiFont.setItalic(font.isItalic());
    poiFont.setUnderline(font.isUnderlined() ? org.apache.poi.ss.usermodel.Font.U_SINGLE
            : org.apache.poi.ss.usermodel.Font.U_NONE);
    poiFont.setStrikeout(font.isStrikeThrough());
    return new PoiFont(this, poiFont);
}
 
開發者ID:xzel23,項目名稱:meja,代碼行數:14,代碼來源:PoiWorkbook.java

示例7: test2

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
@Test
public void test2() throws IOException{
	 Workbook wb = new HSSFWorkbook();
	    Sheet sheet = wb.createSheet("new sheet");

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

	    // Create a cell and put a value in it.
	    

	    // Style the cell with borders all around.
	    CellStyle style = wb.createCellStyle();
	    
	    //     style.setFillBackgroundColor(IndexedColors.AUTOMATIC.getIndex());
	   style.setFillPattern(CellStyle.SOLID_FOREGROUND);
	   style.setFillForegroundColor(IndexedColors.LIGHT_ORANGE.index);
	   
	    Font font = wb.createFont();
	    font.setFontHeightInPoints((short)24);
	    font.setFontName("Courier New");
	    font.setItalic(true);
	    font.setStrikeout(true);
	    style.setFont(font);
	    CellUtil.createCell(row, 1, "nihao",style);
	    //style.setFont(font);
	    // Write the output to a file
	    FileOutputStream fileOut = new FileOutputStream("workbook.xls");
	    wb.write(fileOut);
	    fileOut.close();
}
 
開發者ID:bingyulei007,項目名稱:bingexcel,代碼行數:32,代碼來源:MyTest.java

示例8: main

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithformattingfeatures/workingwithfonts/data/";
	
	Workbook wb = new HSSFWorkbook();
    Sheet sheet = wb.createSheet("new sheet");

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

    // Create a new font and alter it.
    Font 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.
    CellStyle style = wb.createCellStyle();
    style.setFont(font);

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

    // Write the output to a file
    FileOutputStream fileOut = new FileOutputStream(dataPath + "ApacheFonts.xls");
    wb.write(fileOut);
    fileOut.close();
    
    System.out.println("Apache Fonts Created.");
}
 
開發者ID:asposemarketplace,項目名稱:Aspose_for_Apache_POI,代碼行數:34,代碼來源:ApacheWorkingWithFonts.java

示例9: createFont

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
/**
 * Create a new POI Font based upon a BIRT style.
 * @param birtStyle
 * The BIRT style to base the Font upon.
 * @return
 * The Font whose attributes are described by the BIRT style. 
 */
private Font createFont(BirtStyle birtStyle) {
	Font font = workbook.createFont();
	
	// Family
	String fontName = smu.poiFontNameFromBirt(cleanupQuotes(birtStyle.getProperty( StyleConstants.STYLE_FONT_FAMILY )));
	if( fontName == null ) {
		fontName = "Calibri";
	}
	font.setFontName(fontName);
	// Size
	short fontSize = smu.fontSizeInPoints(cleanupQuotes(birtStyle.getProperty( StyleConstants.STYLE_FONT_SIZE )));
	if(fontSize > 0) {
		font.setFontHeightInPoints(fontSize);
	}
	// Weight
	short fontWeight = smu.poiFontWeightFromBirt(cleanupQuotes(birtStyle.getProperty( StyleConstants.STYLE_FONT_WEIGHT )));
	if(fontWeight > 0) {
		font.setBoldweight(fontWeight);
	}
	// Style
	String fontStyle = cleanupQuotes(birtStyle.getProperty( StyleConstants.STYLE_FONT_STYLE ) );
	if( CSSConstants.CSS_ITALIC_VALUE.equals(fontStyle) || CSSConstants.CSS_OBLIQUE_VALUE.equals(fontStyle)) {
		font.setItalic(true);
	}
	// Underline
	String fontUnderline = cleanupQuotes(birtStyle.getProperty( StyleConstants.STYLE_TEXT_UNDERLINE ) );
	if( CSSConstants.CSS_UNDERLINE_VALUE.equals(fontUnderline) ) {
		font.setUnderline(FontUnderline.SINGLE.getByteValue());
	}
	// Colour
	smu.addColourToFont( workbook, font, cleanupQuotes( birtStyle.getProperty( StyleConstants.STYLE_COLOR ) ) );
					
	fonts.add(new FontPair(birtStyle, font));
	return font;
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:43,代碼來源:FontManager.java

示例10: createFont

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
/**
    * Creates a new <code>Font</code> for the given <code>Workbook</code>,
    * with the given attributes.  Moved from <code>StyleTag</code> here for
    * 0.5.0.
    * @param workbook A <code>Workbook</code>.
    * @param fontBoldweight A <code>short</code> boldweight constant.
    * @param fontItalic Whether the text is italic.
    * @param fontColor A color <code>Color</code> opbject.
    * @param fontName A font name.
    * @param fontHeightInPoints A <code>short</code> font height in points.
    * @param fontUnderline A <code>byte</code> underline constant.
    * @param fontStrikeout Whether the font is strikeout.
    * @param fontCharset An <code>int</code> charset constant.
    * @param fontTypeOffset A <code>short</code> type offset constant.
    * @return A new <code>Font</code>.
    */
   public static Font createFont(Workbook workbook, short fontBoldweight, boolean fontItalic, Color fontColor, String fontName, short fontHeightInPoints, byte fontUnderline,
      boolean fontStrikeout, int fontCharset, short fontTypeOffset)
   {
      if (DEBUG)
      {
         System.err.println("createFont: " + fontBoldweight + "," + fontItalic + "," +
            ((fontColor == null) ? "null" :fontColor.toString()
//               (fontColor instanceof HSSFColor) ? fontColor.toString() :
//               ((XSSFColor) fontColor).getCTColor().toString()
            ) + "," + fontName + "," +
            fontHeightInPoints + "," + fontUnderline + "," + fontStrikeout + "," + fontCharset + "," + fontTypeOffset);
      }
      Font f = workbook.createFont();
      f.setBoldweight(fontBoldweight);
      f.setItalic(fontItalic);
      f.setFontName(fontName);
      f.setFontHeightInPoints(fontHeightInPoints);
      f.setUnderline(fontUnderline);
      f.setStrikeout(fontStrikeout);
      f.setCharSet(fontCharset);
      f.setTypeOffset(fontTypeOffset);
      // Color type check.
      if (fontColor instanceof HSSFColor)
      {
         f.setColor(((HSSFColor) fontColor).getIndex());
      }

      return f;
   }
 
開發者ID:rmage,項目名稱:gnvc-ims,代碼行數:46,代碼來源:SheetUtil.java

示例11: XLSXTranslatorOutputFormat

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
/**
 * Public constructor.
 * @param os output stream
 */
public XLSXTranslatorOutputFormat(final OutputStream os) {

  if (os == null) {
    throw new NullPointerException("The output stream is null");
  }

  this.os = os;

  // Temporary files will be compressed
  this.wb.setCompressTempFiles(true);

  // Define default style
  Font defaultFont = this.wb.createFont();
  defaultFont.setFontName("Arial");
  defaultFont.setFontHeightInPoints((short) 10);
  this.defaultStyle = this.wb.createCellStyle();
  this.defaultStyle.setFont(defaultFont);

  // Define header style
  Font headerFont = this.wb.createFont();
  headerFont.setFontName(defaultFont.getFontName());
  headerFont.setFontHeightInPoints(defaultFont.getFontHeightInPoints());
  headerFont.setItalic(true);
  this.headerStyle = this.wb.createCellStyle();
  this.headerStyle.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
  this.headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
  this.headerStyle.setFont(headerFont);

  // Define link style
  Font linkfont = this.wb.createFont();
  linkfont.setFontName(defaultFont.getFontName());
  linkfont.setFontHeightInPoints(defaultFont.getFontHeightInPoints());
  linkfont.setUnderline(XSSFFont.U_SINGLE);
  linkfont.setColor(IndexedColors.BLUE.getIndex());
  this.linkStyle = this.wb.createCellStyle();
  this.linkStyle.setFont(linkfont);
}
 
開發者ID:GenomicParisCentre,項目名稱:eoulsan,代碼行數:42,代碼來源:XLSXTranslatorOutputFormat.java

示例12: createFont

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
private static short createFont(Workbook workbook, FontKey key) {
    Font ret = workbook.createFont();
    if (key.getBoldweight() != null) {
        ret.setBoldweight(key.getBoldweight().shortValue());
    }
    if (key.getCharset() != null) {
        ret.setCharSet(key.getCharset().shortValue());
    }
    if (key.getColor() != null) {
        ret.setColor(key.getColor().shortValue());
    }
    if (key.getFontHeight() != null) {
        ret.setFontHeight(key.getFontHeight().shortValue());
    }
    if (key.getFontHeightInPoints() != null) {
        ret.setFontHeightInPoints(key.getFontHeightInPoints().shortValue());
    }
    if (key.getFontName() != null) {
        ret.setFontName(key.getFontName());
    }
    if (key.getItalic() != null) {
        ret.setItalic(key.getItalic().booleanValue());
    }
    if (key.getStrikeout() != null) {
        ret.setStrikeout(key.getStrikeout().booleanValue());
    }
    if (key.getTypeOffset() != null) {
        ret.setTypeOffset(key.getTypeOffset().shortValue());
    }
    if (key.getUnderLine() != null) {
        ret.setUnderline(key.getUnderLine().byteValue());
    }
    return ret.getIndex();
}
 
開發者ID:brightgenerous,項目名稱:brigen-base,代碼行數:35,代碼來源:CellStyleRegister.java

示例13: update

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
/**
 * 更新
 * @param font
 */
public void update(Font font) {
	if (boldweight != null) {
		font.setBoldweight(boldweight.value());
	}
	if (color != null) {
		font.setColor(color.value());
	}
	if (fontHeight != null) {
		font.setFontHeight(fontHeight);
	}
	if (fontHeightInPoints != null) {
		font.setFontHeightInPoints(fontHeightInPoints);
	}
	if (fontName != null) {
		font.setFontName(fontName);
		font.setCharSet(Font.DEFAULT_CHARSET);
	}
	if (italic != null) {
		font.setItalic(italic);
	}
	if (strikeout != null) {
		font.setStrikeout(strikeout);
	}
	if (typeOffset != null) {
		font.setTypeOffset(typeOffset.value());
	}
	if (underline != null) {
		font.setUnderline(underline.value());
	}
}
 
開發者ID:yu-ki106f,項目名稱:PoiManager,代碼行數:35,代碼來源:PoiFontDto.java

示例14: createCommentFont

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
public static Font createCommentFont( Workbook workbook, cfStructData _struct ) throws Exception {
	Font font = workbook.createFont();
	
	if ( _struct.containsKey("bold") ){
		if ( _struct.getData("bold").getBoolean() )
			font.setBoldweight( Font.BOLDWEIGHT_BOLD );
		else
			font.setBoldweight( Font.BOLDWEIGHT_NORMAL );
	}
	
	if ( _struct.containsKey("color") ){
		String v 	= _struct.getData("color").getString();
		Short s 	= lookup_colors.get( v );
		if ( s == null ){
			throw new Exception( "invalid parameter for 'color' (" + v + ")" );
		}else
			font.setColor( s );
	}
	
	if ( _struct.containsKey("font") ){
		font.setFontName( _struct.getData("font").getString() );
	}
	
	if ( _struct.containsKey("italic") ){
		font.setItalic( _struct.getData("italic").getBoolean() );
	}
	
	if ( _struct.containsKey("strikeout") ){
		font.setStrikeout( _struct.getData("strikeout").getBoolean() );
	}
	
	if ( _struct.containsKey("underline") ){
		font.setUnderline( (byte)_struct.getData("underline").getInt() );
	}

	if ( _struct.containsKey("size") ){
		font.setFontHeightInPoints( (short)_struct.getData("size").getInt() );
	}
	
	return font;
}
 
開發者ID:OpenBD,項目名稱:openbd-core,代碼行數:42,代碼來源:SpreadSheetFormatOptions.java

示例15: getItalicFont

import org.apache.poi.ss.usermodel.Font; //導入方法依賴的package包/類
public Font getItalicFont(Workbook wb, short size) {
	final String key = "italic" + size;
	
	Font font = fonts.get(key);
	if (font == null) {
		font = wb.createFont();
		font.setFontHeightInPoints(size);
		font.setItalic(true);
		
		fonts.put(key, font);
	}
	return font;
}
 
開發者ID:sigmah-dev,項目名稱:sigmah,代碼行數:14,代碼來源:ExcelUtils.java


注:本文中的org.apache.poi.ss.usermodel.Font.setItalic方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。