本文整理了Java中org.apache.poi.hssf.usermodel.HSSFFont.setBoldweight()
方法的一些代码示例,展示了HSSFFont.setBoldweight()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HSSFFont.setBoldweight()
方法的具体详情如下:
包路径:org.apache.poi.hssf.usermodel.HSSFFont
类名称:HSSFFont
方法名:setBoldweight
[英]set the boldness to use
[中]设置要使用的粗体
代码示例来源:origin: rakam-io/rakam
boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
代码示例来源:origin: stackoverflow.com
private HSSFFont createAndSetFontStyle(HSSFWorkbook wb) {
HSSFFont font = wb.createFont();
font.setFontName(XSSFFont.DEFAULT_FONT_NAME);
font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short)10);
return font;
}
HSSFCellStyle cellStyle = workBook.createCellStyle();
HSSFFont createfont = createAndSetFontStyle(workBook);
cellStyle.setFont(createfont);
cell.setCellStyle(cellStyle);
代码示例来源:origin: TomasKypta/android-lang-tool
private static HSSFCellStyle createKeyStyle(HSSFWorkbook wb) {
HSSFFont bold = wb.createFont();
bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
bold.setFontHeightInPoints((short)11);
HSSFCellStyle keyStyle = wb.createCellStyle();
keyStyle.setFont(bold);
return keyStyle;
}
代码示例来源:origin: stackoverflow.com
HSSFFont boldFont = wb.createFont();
boldFont.setFontHeightInPoints((short)22);
boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); //Setting Bold font
HSSFCellStyle boldStyle = wb.createCellStyle();
boldStyle.setFont(boldFont); //Attaching the font to the Style
HSSFRow row = sheet1.createRow((short)1);
HSSFCell cell = row.createCell((short)0);
cell.setCellValue("This quick brown fox");
cell.setCellStyle(boldStyle); //Applying Style to the Cell.
代码示例来源:origin: paypal/SeLion
private static HSSFFont createCustomFont(short colorIndex, Byte underlineWeight) {
HSSFFont font = wb1.createFont();
font.setFontName(HSSFFont.FONT_ARIAL);
font.setFontHeightInPoints((short) 10);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setColor(colorIndex);
font.setUnderline(underlineWeight);
return font;
}
代码示例来源:origin: com.dexcoder/dexcoder-commons
/**
* 生成sheet列标题行
*
* @param workbook 工作薄对象
* @param sheet sheet对象
* @param excelSheet the excel sheet
*/
public void createTitle(HSSFWorkbook workbook, HSSFSheet sheet, ExcelSheet excelSheet) {
// 创建表格标题行
HSSFRow row = sheet.createRow(0);
List<String> rowTitles = excelSheet.getRowTitles();
for (int i = 0; i < rowTitles.size(); i++) {
HSSFCell cell = row.createCell(i);
HSSFRichTextString text = new HSSFRichTextString(rowTitles.get(i));
HSSFFont font = workbook.createFont();
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
text.applyFont(font);
cell.setCellValue(text);
}
}
代码示例来源:origin: selfly/dexcoder-assistant
/**
* 生成sheet列标题行
*
* @param workbook 工作薄对象
* @param sheet sheet对象
* @param excelSheet the excel sheet
*/
public void createTitle(HSSFWorkbook workbook, HSSFSheet sheet, ExcelSheet excelSheet) {
// 创建表格标题行
HSSFRow row = sheet.createRow(0);
List<String> rowTitles = excelSheet.getRowTitles();
for (int i = 0; i < rowTitles.size(); i++) {
HSSFCell cell = row.createCell(i);
HSSFRichTextString text = new HSSFRichTextString(rowTitles.get(i));
HSSFFont font = workbook.createFont();
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
text.applyFont(font);
cell.setCellValue(text);
}
}
代码示例来源:origin: org.sakaiproject.assignment/sakai-assignment-impl
private HSSFCellStyle createHeaderStyle(){
//TO-DO read style information from sakai.properties
HSSFFont font = gradesWorkbook.createFont();
font.setFontName(HSSFFont.FONT_ARIAL);
font.setColor(IndexedColors.PLUM.getIndex());
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
HSSFCellStyle cellStyle = gradesWorkbook.createCellStyle();
cellStyle.setFont(font);
return cellStyle;
}
代码示例来源:origin: displaytag/displaytag-export-poi
/**
* Obtain the style used to render a header or footer.
* @return The style used to render a header or footer.
*/
private HSSFCellStyle getHeaderFooterStyle()
{
HSSFCellStyle style = this.wb.createCellStyle();
style.setFillPattern(HSSFCellStyle.FINE_DOTS);
style.setFillBackgroundColor(HSSFColor.BLUE_GREY.index);
HSSFFont bold = this.wb.createFont();
bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
bold.setColor(HSSFColor.WHITE.index);
style.setFont(bold);
return style;
}
代码示例来源:origin: TomasKypta/android-lang-tool
private static HSSFCellStyle createTilteStyle(HSSFWorkbook wb) {
HSSFFont bold = wb.createFont();
bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
HSSFCellStyle style = wb.createCellStyle();
style.setFont(bold);
style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style.setWrapText(true);
return style;
}
代码示例来源:origin: com.github.mg365/mg-common
/**
* 设置Excel表头字体颜色
*
* @param wb Excel文件
* @return: 字体对象
*/
private HSSFCellStyle createRedFont(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
style.setFont(font);
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
return style;
}
代码示例来源:origin: choerodon/choerodon-starters
/**
* 设置Excel图片的格式:字体居中、变粗、蓝色、12号
*
* @param headerStyle 头部样式
* @param book 生产的excel book HSSFWorkbook对象
* @author chenssy
* @date 2014年6月16日 下午8:46:49
* @version 1.0
*/
private static void setHeaderStyle(HSSFCellStyle headerStyle, HSSFWorkbook book) {
headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); //水平居中
headerStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
//设置字体
HSSFFont font = book.createFont();
font.setFontHeightInPoints((short) 12); //字号:12号
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); //变粗
font.setColor(HSSFColor.BLUE.index); //蓝色
headerStyle.setFont(font);
}
}
代码示例来源:origin: io.choerodon/choerodon-starter-core
/**
* 设置Excel图片的格式:字体居中、变粗、蓝色、12号
*
* @param headerStyle 头部样式
* @param book 生产的excel book HSSFWorkbook对象
* @author chenssy
* @date 2014年6月16日 下午8:46:49
* @version 1.0
*/
private static void setHeaderStyle(HSSFCellStyle headerStyle, HSSFWorkbook book) {
headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); //水平居中
headerStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
//设置字体
HSSFFont font = book.createFont();
font.setFontHeightInPoints((short) 12); //字号:12号
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); //变粗
font.setColor(HSSFColor.BLUE.index); //蓝色
headerStyle.setFont(font);
}
}
代码示例来源:origin: org.seasar.tuigwaa/tuigwaa-ext
private void createDefaultHeaderCellStyle() {
headerCellStyle = workbook.createCellStyle();
HSSFFont font = workbook.createFont();
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setColor(HSSFColor.WHITE.index);
headerCellStyle.setFont(font);
headerCellStyle
.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index);
headerCellStyle.setFillPattern(HSSFCellStyle.FINE_DOTS);
headerCellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
headerCellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
}
代码示例来源:origin: stackoverflow.com
//////////////////////Excel Header Style/////////////////////////
HSSFCellStyle headerlabelcs = wb.createCellStyle();
headerlabelcs.setFillForegroundColor(HSSFColor.PALE_BLUE.index);
headerlabelcs.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
headerlabelcs.setBorderLeft((short)1);
headerlabelcs.setBorderRight((short)1);
HSSFFont headerlabelfont = wb.createFont();
headerlabelfont.setFontHeightInPoints((short)12);
headerlabelfont.setFontName("Calibri");
headerlabelfont.setColor(HSSFColor.BLACK.index);
headerlabelfont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
headerlabelcs.setFont(headerlabelfont);
//////////////////////Excel Header Style/////////////////////////
代码示例来源:origin: Impetus/jumbune
/**
* Sets header style
* @param worksheet the worksheet
* @param fontName font name
* @param fontColor font color
* @param fontBoldweight font weight
*/
public static void setHeaderStyle(Worksheet worksheet, String fontName,
short fontColor, short fontBoldweight) {
HSSFWorkbook workbook = worksheet.getWorkbook();
HSSFFont font = workbook.createFont();
font.setFontName(fontName);
font.setColor(fontColor);
font.setBoldweight(fontBoldweight);
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFont(font);
worksheet.setCellStyle(cellStyle);
}
代码示例来源:origin: riotfamily/riot
private void createHeadings(String... labels) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setFontName("Trebuchet MS");
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
style.setFont(font);
HSSFRow row = sheet.createRow(0);
int col = 0;
for (String label : labels) {
HSSFCell cell = row.createCell(col++);
cell.setCellStyle(style);
cell.setCellValue(new HSSFRichTextString(label));
}
}
代码示例来源:origin: riotfamily/riot
private void createHeadings(String... labels) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setFontName("Trebuchet MS");
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
style.setFont(font);
HSSFRow row = sheet.createRow(0);
int col = 0;
for (String label : labels) {
HSSFCell cell = row.createCell(col++);
cell.setCellStyle(style);
cell.setCellValue(new HSSFRichTextString(label));
}
}
代码示例来源:origin: com.jalalkiswani/jk-util
/**
*/
protected void createColumnHeaders() {
final HSSFRow headersRow = this.sheet.createRow(0);
final HSSFFont font = this.workbook.createFont();
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
final HSSFCellStyle style = this.workbook.createCellStyle();
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
int counter = 1;
for (int i = 0; i < this.model.getColumnCount(); i++) {
final HSSFCell cell = headersRow.createCell(counter++);
// cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(this.model.getColumnName(i));
cell.setCellStyle(style);
}
}
代码示例来源:origin: displaytag/displaytag-export-poi
/**
* @see org.displaytag.render.TableWriterTemplate#writeCaption(org.displaytag.model.TableModel)
*/
protected void writeCaption(TableModel model) throws Exception
{
HSSFCellStyle style = this.wb.createCellStyle();
HSSFFont bold = this.wb.createFont();
bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
bold.setFontHeightInPoints((short) 14);
style.setFont(bold);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
this.colNum = 0;
this.currentRow = this.sheet.createRow(this.rowNum++);
this.currentCell = this.currentRow.createCell(this.colNum);
this.currentCell.setCellStyle(style);
String caption = model.getCaption();
this.currentCell.setCellValue(new HSSFRichTextString(caption));
this.rowSpanTable(model);
}
内容来源于网络,如有侵权,请联系作者删除!