本文整理汇总了Java中org.apache.poi.ss.usermodel.Font.setStrikeout方法的典型用法代码示例。如果您正苦于以下问题:Java Font.setStrikeout方法的具体用法?Java Font.setStrikeout怎么用?Java Font.setStrikeout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.ss.usermodel.Font
的用法示例。
在下文中一共展示了Font.setStrikeout方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
示例2: 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());
}
}
}
示例3: 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);
}
示例4: 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();
}
示例5: 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.");
}
示例6: 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;
}
示例7: 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();
}
示例8: 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());
}
}
示例9: 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;
}
示例10: netxiliaStyle2Poi
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
public static CellStyle netxiliaStyle2Poi(Styles nxStyle, Workbook workbook, CellStyle poiStyle) {
if (nxStyle == null) {
return poiStyle;
}
poiStyle.setWrapText(nxStyle.contains(DefaultStyle.nowrap.getStyle()));
// font
short bold = nxStyle.contains(DefaultStyle.bold.getStyle()) ? Font.BOLDWEIGHT_BOLD : Font.BOLDWEIGHT_NORMAL;
byte underline = nxStyle.contains(DefaultStyle.underline.getStyle()) ? Font.U_SINGLE : Font.U_NONE;
boolean italic = nxStyle.contains(DefaultStyle.italic.getStyle());
boolean strikeout = nxStyle.contains(DefaultStyle.strikeout.getStyle());
Font defaultFont = workbook.getFontAt(poiStyle.getFontIndex());
Font font = workbook.findFont(bold, defaultFont.getColor(), defaultFont.getFontHeight(),
defaultFont.getFontName(), italic, strikeout, defaultFont.getTypeOffset(), underline);
if (font == null) {
font = workbook.createFont();
font.setBoldweight(bold);
font.setItalic(italic);
font.setUnderline(underline);
font.setStrikeout(strikeout);
}
poiStyle.setFont(font);
// borders
if (nxStyle.contains(DefaultStyle.borderLeft.getStyle())) {
poiStyle.setBorderLeft(CellStyle.BORDER_THIN);
}
if (nxStyle.contains(DefaultStyle.borderRight.getStyle())) {
poiStyle.setBorderRight(CellStyle.BORDER_THIN);
}
if (nxStyle.contains(DefaultStyle.borderTop.getStyle())) {
poiStyle.setBorderTop(CellStyle.BORDER_THIN);
}
if (nxStyle.contains(DefaultStyle.borderBottom.getStyle())) {
poiStyle.setBorderBottom(CellStyle.BORDER_THIN);
}
// align
if (nxStyle.contains(DefaultStyle.alignLeft.getStyle())) {
poiStyle.setAlignment(CellStyle.ALIGN_LEFT);
} else if (nxStyle.contains(DefaultStyle.alignRight.getStyle())) {
poiStyle.setAlignment(CellStyle.ALIGN_RIGHT);
} else if (nxStyle.contains(DefaultStyle.alignCenter.getStyle())) {
poiStyle.setAlignment(CellStyle.ALIGN_CENTER);
} else if (nxStyle.contains(DefaultStyle.alignJustify.getStyle())) {
poiStyle.setAlignment(CellStyle.ALIGN_JUSTIFY);
}
return poiStyle;
}