java font.bold_Java Font.getBoldweight方法代码示例

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类

/**

* Find a CellStyle with all the same attributes as the given

* CellStyle but with the given font index.

* @param workbook The Workbook.

* @param cellStyle The CellStyle to find.

* @param font The Font to find.

* @return The CellStyle from the Workbook if

* found, or null if not found.

*/

private static CellStyle findCellStyle(Workbook workbook, CellStyle cellStyle, Font font)

{

int numCellStyles = workbook.getNumCellStyles();

for (short i = 0; i < numCellStyles; i++)

{

CellStyle cs = workbook.getCellStyleAt(i);

Font f = workbook.getFontAt(cs.getFontIndex());

if (cs.getFillForegroundColor() == cellStyle.getFillForegroundColor() &&

cs.getFillBackgroundColor() == cellStyle.getFillBackgroundColor() &&

cs.getDataFormat() == cellStyle.getDataFormat() &&

cs.getAlignment() == cellStyle.getAlignment() &&

cs.getBorderBottom() == cellStyle.getBorderBottom() &&

cs.getBorderLeft() == cellStyle.getBorderLeft() &&

cs.getBorderRight() == cellStyle.getBorderRight() &&

cs.getBorderTop() == cellStyle.getBorderTop() &&

cs.getFillPattern() == cellStyle.getFillPattern() &&

cs.getWrapText() == cellStyle.getWrapText() &&

cs.getRotation() == cellStyle.getRotation() &&

cs.getBottomBorderColor() == cellStyle.getBottomBorderColor() &&

cs.getTopBorderColor() == cellStyle.getTopBorderColor() &&

cs.getLeftBorderColor() == cellStyle.getLeftBorderColor() &&

cs.getRightBorderColor() == cellStyle.getRightBorderColor() &&

cs.getVerticalAlignment() == cellStyle.getVerticalAlignment() &&

cs.getIndention() == cellStyle.getIndention() &&

cs.getLocked() == cellStyle.getLocked() &&

cs.getHidden() == cellStyle.getHidden() &&

f.getBoldweight() == font.getBoldweight() &&

f.getItalic() == font.getItalic() &&

f.getColor() == font.getColor() &&

f.getFontHeight() == font.getFontHeight() &&

f.getUnderline() == font.getUnderline() &&

f.getFontName().equals(font.getFontName()) &&

f.getTypeOffset() == font.getTypeOffset()

)

{

if (!(font instanceof XSSFFont && f instanceof XSSFFont) ||

((XSSFFont) font).getXSSFColor().getARGBHex().equals(((XSSFFont) f).getXSSFColor().getARGBHex()))

{

if (DEBUG)

System.err.println(" Found existing, matching CellStyle with the Font!");

return cs;

}

}

}

if (DEBUG)

System.err.println(" Did NOT find existing, matching CellStyle with the Font!");

return null;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值