本文整理汇总了Java中org.apache.poi.ss.usermodel.Font.setBoldweight方法的典型用法代码示例。如果您正苦于以下问题:Java Font.setBoldweight方法的具体用法?Java Font.setBoldweight怎么用?Java Font.setBoldweight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.ss.usermodel.Font
的用法示例。
在下文中一共展示了Font.setBoldweight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeHeader
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
private void makeHeader ( final List<Field> columns, final HSSFSheet sheet )
{
final Font font = sheet.getWorkbook ().createFont ();
font.setFontName ( "Arial" );
font.setBoldweight ( Font.BOLDWEIGHT_BOLD );
font.setColor ( HSSFColor.WHITE.index );
final CellStyle style = sheet.getWorkbook ().createCellStyle ();
style.setFont ( font );
style.setFillForegroundColor ( HSSFColor.BLACK.index );
style.setFillPattern ( PatternFormatting.SOLID_FOREGROUND );
final HSSFRow row = sheet.createRow ( 0 );
for ( int i = 0; i < columns.size (); i++ )
{
final Field field = columns.get ( i );
final HSSFCell cell = row.createCell ( i );
cell.setCellValue ( field.getHeader () );
cell.setCellStyle ( style );
}
}
示例2: createStyles
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
* 创建表格样式
* @param wb 工作薄对象
* @return 样式列表
*/
private Map<String, CellStyle> createStyles(Workbook wb) {
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
CellStyle style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
Font titleFont = wb.createFont();
titleFont.setFontName("Arial");
titleFont.setFontHeightInPoints((short) 16);
titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
style.setFont(titleFont);
styles.put("title", style);
style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setBorderRight(CellStyle.BORDER_THIN);
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderTop(CellStyle.BORDER_THIN);
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
Font dataFont = wb.createFont();
dataFont.setFontName("Arial");
dataFont.setFontHeightInPoints((short) 10);
style.setFont(dataFont);
styles.put("data", style);
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
style.setAlignment(CellStyle.ALIGN_LEFT);
styles.put("data1", style);
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
style.setAlignment(CellStyle.ALIGN_CENTER);
styles.put("data2", style);
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
style.setAlignment(CellStyle.ALIGN_RIGHT);
styles.put("data3", style);
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
// style.setWrapText(true);
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
Font headerFont = wb.createFont();
headerFont.setFontName("Arial");
headerFont.setFontHeightInPoints((short) 10);
headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
headerFont.setColor(IndexedColors.WHITE.getIndex());
style.setFont(headerFont);
styles.put("header", style);
return styles;
}
示例3: createHeadStyle
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
CellStyle createHeadStyle() {
if (headerCellStyle != null) {
return headerCellStyle;
}
CellStyle style = wb.createCellStyle();
// 设置这些样式
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index);
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setAlignment(CellStyle.ALIGN_CENTER);
// 生成一个字体
Font font = wb.createFont();
font.setColor(IndexedColors.BLACK.index);
font.setFontHeightInPoints((short) 12);
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
// 把字体应用到当前的样式
style.setFont(font);
headerCellStyle = style;
return style;
}
示例4: createHeadDateStyle
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
CellStyle createHeadDateStyle() {
if (headDateCellStyle != null) {
return headDateCellStyle;
}
CellStyle cellStyle = wb.createCellStyle();
DataFormat format = wb.createDataFormat();
cellStyle.setDataFormat(format.getFormat("m/d/yy h:mm"));
// 设置这些样式
cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index);
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
// 生成一个字体
Font font = wb.createFont();
font.setColor(IndexedColors.BLACK.index);
font.setFontHeightInPoints((short) 12);
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
// 把字体应用到当前的样式
cellStyle.setFont(font);
headDateCellStyle = cellStyle;
return cellStyle;
}
示例5: 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);
}
示例6: 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())));
}
}
示例7: createStyles
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
* excel 样式
*
* @return
*/
public Map<String, CellStyle> createStyles(Workbook workbook) {
Map<String, CellStyle> styles = new HashMap();
CellStyle style = workbook.createCellStyle();
style.setAlignment((short) 2);
style.setVerticalAlignment((short) 1);
Font titleFont = workbook.createFont();
titleFont.setFontName("Arial");
titleFont.setFontHeightInPoints((short) 16);
titleFont.setBoldweight((short) 700);
style.setFont(titleFont);
styles.put("title", style);
style = workbook.createCellStyle();
style.setVerticalAlignment((short) 1);
style.setBorderRight((short) 1);
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderLeft((short) 1);
style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderTop((short) 1);
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderBottom((short) 1);
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
Font dataFont = workbook.createFont();
dataFont.setFontName("Arial");
dataFont.setFontHeightInPoints((short) 10);
style.setFont(dataFont);
styles.put("data", style);
style = workbook.createCellStyle();
style.cloneStyleFrom((CellStyle) styles.get("data"));
style.setAlignment((short) 1);
styles.put("data1", style);
style = workbook.createCellStyle();
style.cloneStyleFrom((CellStyle) styles.get("data"));
style.setAlignment((short) 2);
styles.put("data2", style);
style = workbook.createCellStyle();
style.cloneStyleFrom((CellStyle) styles.get("data"));
style.setAlignment((short) 3);
styles.put("data3", style);
style = workbook.createCellStyle();
style.cloneStyleFrom((CellStyle) styles.get("data"));
style.setAlignment((short) 2);
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setFillPattern((short) 1);
Font headerFont = workbook.createFont();
headerFont.setFontName("Arial");
headerFont.setFontHeightInPoints((short) 10);
headerFont.setBoldweight((short) 700);
headerFont.setColor(IndexedColors.WHITE.getIndex());
style.setFont(headerFont);
styles.put("header", style);
return styles;
}
示例8: setCommonStyle
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
* 设置通用的对齐居中、边框等
*
* @param style 样式
*/
private void setCommonStyle(CellStyle style) {
// 设置单元格居中对齐、自动换行
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setWrapText(true);
//设置单元格字体
if (!buildInFontMap.containsKey(FONT_KEY)) {
Font font = workbook.createFont();
//通用字体
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontName("宋体");
font.setFontHeight((short) 200);
buildInFontMap.put(FONT_KEY, font);
}
style.setFont(buildInFontMap.get(FONT_KEY));
// 设置单元格边框为细线条
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderTop(CellStyle.BORDER_THIN);
}
示例9: getHeadCellStyle
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
*
* @Title: getCellStyle
* @Description: TODO(设置表头样式)
* @param wb
* @return
*/
private CellStyle getHeadCellStyle(Workbook wb) {
CellStyle style = wb.createCellStyle();
Font font = wb.createFont();
font.setFontName("宋体");
font.setFontHeightInPoints((short) 12);// 设置字体大小
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 加粗
style.setFillForegroundColor(HSSFColor.LIME.index);// 设置背景色
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
style.setAlignment(HSSFCellStyle.SOLID_FOREGROUND);// 让单元格居中
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style.setBorderTop(CellStyle.BORDER_THIN);
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderBottom(CellStyle.BORDER_THIN);
// style.setWrapText(true);//设置自动换行
style.setFont(font);
return style;
}
示例10: getHeaderStyle
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
* header样式
*
* @return
*/
public CellStyle getHeaderStyle() {
CellStyle headerStyle = workbook.createCellStyle();
// 设置单元格的背景颜色为淡蓝色
headerStyle.setFillForegroundColor(HSSFColor.PALE_BLUE.index);
headerStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
// 设置单元格居中对齐
headerStyle.setAlignment(CellStyle.ALIGN_CENTER);
// 设置单元格垂直居中对齐
headerStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
// 创建单元格内容显示不下时自动换行
headerStyle.setWrapText(true);
// 设置单元格字体样式
Font font = workbook.createFont();
// 设置字体加粗
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontName("宋体");
font.setFontHeight((short) 200);
headerStyle.setFont(font);
// 设置单元格边框为细线条
setBorder(headerStyle);
return headerStyle;
}
示例11: getTextStyle
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
* 文本样式
*
* @return
*/
public CellStyle getTextStyle() {
CellStyle textStyle = workbook.createCellStyle();
// 设置单元格居中对齐
textStyle.setAlignment(CellStyle.ALIGN_CENTER);
// 设置单元格垂直居中对齐
textStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
// 创建单元格内容显示不下时自动换行
textStyle.setWrapText(true);
// 设置单元格字体样式
Font font = workbook.createFont();
// 设置字体加粗
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontName("宋体");
font.setFontHeight((short) 200);
textStyle.setFont(font);
// 设置单元格边框为细线条
setBorder(textStyle);
return textStyle;
}
示例12: getNumberStyle
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
public CellStyle getNumberStyle() {
CellStyle numberStyle = workbook.createCellStyle();
// 设置单元格居中对齐
numberStyle.setAlignment(CellStyle.ALIGN_CENTER);
// 设置单元格垂直居中对齐
numberStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
// 创建单元格内容显示不下时自动换行
numberStyle.setWrapText(true);
// 设置单元格字体样式
Font font = workbook.createFont();
// 设置字体加粗
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontName("宋体");
font.setFontHeight((short) 200);
numberStyle.setFont(font);
// 设置单元格边框为细线条
setBorder(numberStyle);
return numberStyle;
}
示例13: getDateStyle
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
public CellStyle getDateStyle() {
CellStyle dateStyle = workbook.createCellStyle();
// 设置单元格居中对齐
dateStyle.setAlignment(CellStyle.ALIGN_CENTER);
// 设置单元格垂直居中对齐
dateStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
DataFormat format = workbook.createDataFormat();
dateStyle.setDataFormat(format.getFormat("yyyy-MM-dd HH:mm"));
// 创建单元格内容显示不下时自动换行
dateStyle.setWrapText(true);
// 设置单元格字体样式
Font font = workbook.createFont();
// 设置字体加粗
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontName("宋体");
font.setFontHeight((short) 200);
dateStyle.setFont(font);
setBorder(dateStyle);
return dateStyle;
}
示例14: createTitle
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
protected void createTitle() {
short lineThickness = (short) (6 * BASE_HEIGHT);
// Top Line
Row row = sheet.createRow(ROW_4);
row.setHeight(lineThickness);
XSSFCellStyle style = wb.createCellStyle();
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
setDummyTitleStyle(row,style);
// Title
row = sheet.createRow(ROW_5);
row.setHeightInPoints(100);
sheet.addMergedRegion(CellRangeAddress.valueOf("B5:G5"));
Font font = wb.createFont();
font.setFontHeightInPoints((short)28);
font.setFontName("Trebuchet MS");
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
style = wb.createCellStyle();
style.setFont(font);
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
setDummyTitleStyle(row,style);
row.getCell(COL_B).setCellValue("Open Source License Verification Report");
// Bottom Line
row = sheet.createRow(ROW_6);
row.setHeight(lineThickness);
style = wb.createCellStyle();
style.setFillForegroundColor(DARK_BLUE);
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
setDummyTitleStyle(row,style);
}
示例15: getHeaderCellStyle
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
private CellStyle getHeaderCellStyle(final Workbook wb) {
CellStyle cellStyle = wb.createCellStyle();
Font boldFont = wb.createFont();
boldFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
cellStyle.setFont(boldFont);
return cellStyle;
}