当前位置: 首页>>代码示例>>Java>>正文


Java Font.setUnderline方法代码示例

本文整理汇总了Java中org.apache.poi.ss.usermodel.Font.setUnderline方法的典型用法代码示例。如果您正苦于以下问题:Java Font.setUnderline方法的具体用法?Java Font.setUnderline怎么用?Java Font.setUnderline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.ss.usermodel.Font的用法示例。


在下文中一共展示了Font.setUnderline方法的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: initFonts

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
 * Initialisation des polices
 */
protected void initFonts() {
	Font fontHeader = workbook.createFont();
	fontHeader.setFontHeightInPoints(getHeaderFontHeight());
	fontHeader.setFontName(getFontName());
	fontHeader.setBoldweight(Font.BOLDWEIGHT_BOLD);
	setFontColor(fontHeader, colorRegistry, HEADER_FONT_COLOR_INDEX);
	registerFont(FONT_HEADER_NAME, fontHeader);

	Font fontNormal = workbook.createFont();
	fontNormal.setFontHeightInPoints(getNormalFontHeight());
	fontNormal.setFontName(getFontName());
	registerFont(FONT_NORMAL_NAME, fontNormal);
	
	Font fontLink = workbook.createFont();
	fontLink.setFontHeightInPoints(getNormalFontHeight());
	fontLink.setFontName(getFontName());
	fontLink.setUnderline(Font.U_SINGLE);
	setFontColor(fontLink, colorRegistry, LINK_FONT_COLOR_INDEX);
	registerFont(FONT_LINK_NAME, fontLink);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:24,代码来源:AbstractExcelTableExport.java

示例3: createLinkStyle

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
private CellStyle createLinkStyle(boolean bordered) {
	final Font hlinkFont = wb.createFont();
	hlinkFont.setUnderline(Font.U_SINGLE);
	hlinkFont.setColor(IndexedColors.BLUE.getIndex());
	
	final CellStyle style;
	if (bordered) {
		style = createBorderedStyle(wb);
	} else {
		style = wb.createCellStyle();
	}
	
	style.setFont(hlinkFont);
	style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
	style.setIndention((short) 1);
	style.setWrapText(true);
	
	return style;
}
 
开发者ID:sigmah-dev,项目名称:sigmah,代码行数:20,代码来源:ExcelUtils.java

示例4: 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

示例5: 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

示例6: 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

示例7: setLink

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
 * Set a link to a cell. The link type should one of {@link Hyperlink}
 * 
 * @param wb
 *            the workbook which contains the cell
 * @param cell
 *            the cell where the link is stored
 * @param address
 *            the cell destination address
 * @param linkType
 *            the type selected among {@link Hyperlink}
 */
public static void setLink(Workbook wb, HSSFCell cell, String address, int linkType) {
	CreationHelper helper = wb.getCreationHelper();
	CellStyle style = wb.createCellStyle();
	Font font = wb.createFont();
	font.setUnderline(Font.U_SINGLE);
	font.setColor(IndexedColors.BLUE.getIndex());
	style.setFont(font);

	Hyperlink link = helper.createHyperlink(linkType);
	link.setAddress(address);
	cell.setHyperlink(link);
	cell.setCellStyle(style);
}
 
开发者ID:turnus,项目名称:turnus,代码行数:26,代码来源:PoiUtils.java

示例8: 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

示例9: main

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
public static void main(String[] args)throws Exception
{
	String dataPath = "src/featurescomparison/workingwithdata/hyperlink/data/";
	
	Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
    CreationHelper createHelper = wb.getCreationHelper();

    //cell style for hyperlinks
    //by default hyperlinks are blue and underlined
    CellStyle hlink_style = wb.createCellStyle();
    Font hlink_font = wb.createFont();
    hlink_font.setUnderline(Font.U_SINGLE);
    hlink_font.setColor(IndexedColors.BLUE.getIndex());
    hlink_style.setFont(hlink_font);

    Cell cell;
    Sheet sheet = wb.createSheet("Hyperlinks");
    //URL
    cell = sheet.createRow(0).createCell((short)0);
    cell.setCellValue("URL Link");

    Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL);
    link.setAddress("http://poi.apache.org/");
    cell.setHyperlink(link);
    cell.setCellStyle(hlink_style);

    //link to a file in the current directory
    cell = sheet.createRow(1).createCell((short)0);
    cell.setCellValue("File Link");
    link = createHelper.createHyperlink(Hyperlink.LINK_FILE);
    link.setAddress("link1.xls");
    cell.setHyperlink(link);
    cell.setCellStyle(hlink_style);

    //e-mail link
    cell = sheet.createRow(2).createCell((short)0);
    cell.setCellValue("Email Link");
    link = createHelper.createHyperlink(Hyperlink.LINK_EMAIL);
    //note, if subject contains white spaces, make sure they are url-encoded
    link.setAddress("mailto:[email protected]?subject=Hyperlinks");
    cell.setHyperlink(link);
    cell.setCellStyle(hlink_style);

    //link to a place in this workbook

    //create a target sheet and cell
    Sheet sheet2 = wb.createSheet("Target Sheet");
    sheet2.createRow(0).createCell((short)0).setCellValue("Target Cell");

    cell = sheet.createRow(3).createCell((short)0);
    cell.setCellValue("Worksheet Link");
    Hyperlink link2 = createHelper.createHyperlink(Hyperlink.LINK_DOCUMENT);
    link2.setAddress("'Target Sheet'!A1");
    cell.setHyperlink(link2);
    cell.setCellStyle(hlink_style);

    FileOutputStream out = new FileOutputStream(dataPath + "ApacheHyperlinks.xlsx");
    wb.write(out);
    out.close();
    
    System.out.println("Done..");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:63,代码来源:ApacheHyperlinks.java

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: setupStyles

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
 * Setup styles.
 */
private void setupStyles() {
    styleTitle = wb.createCellStyle();
    Font title_font = wb.createFont();
    title_font.setFontName("Helvetica");
    title_font.setColor(IndexedColors.BLACK.getIndex());
    title_font.setFontHeightInPoints((short) 24);
    styleTitle.setFont(title_font);

    styleSubtitle = wb.createCellStyle();
    Font subtitle_font = wb.createFont();
    subtitle_font.setFontName("Helvetica");
    subtitle_font.setColor(IndexedColors.GREY_50_PERCENT.getIndex());
    subtitle_font.setFontHeightInPoints((short) 18);
    styleSubtitle.setFont(subtitle_font);

    styleHyperlink = wb.createCellStyle();
    Font hlink_font = wb.createFont();
    hlink_font.setFontName("Helvetica");
    hlink_font.setUnderline(Font.U_SINGLE);
    hlink_font.setColor(IndexedColors.BLUE.getIndex());
    styleHyperlink.setFont(hlink_font);

    styleNormal = wb.createCellStyle();
    Font normal_font = wb.createFont();
    normal_font.setFontName("Helvetica");
    normal_font.setColor(IndexedColors.BLACK.getIndex());
    normal_font.setFontHeightInPoints((short) 12);
    styleNormal.setFont(normal_font);
    styleNormal.setWrapText(true);

    styleHeader = wb.createCellStyle();
    Font header_font = wb.createFont();
    header_font.setFontName("Helvetica");
    header_font.setColor(IndexedColors.WHITE.getIndex());
    header_font.setBold(true);
    header_font.setFontHeightInPoints((short) 12);
    XSSFColor bg = new XSSFColor(new java.awt.Color(0x28, 0x60, 0x90));
    ((XSSFCellStyle) styleHeader).setFillForegroundColor(bg);
    styleHeader.setFillPattern(CellStyle.SOLID_FOREGROUND);
    styleHeader.setFont(header_font);

}
 
开发者ID:frizbog,项目名称:gedantic,代码行数:46,代码来源:WorkbookCreator.java


注:本文中的org.apache.poi.ss.usermodel.Font.setUnderline方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。