本文整理了Java中org.apache.poi.hssf.usermodel.HSSFFont.setFontName()
方法的一些代码示例,展示了HSSFFont.setFontName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HSSFFont.setFontName()
方法的具体详情如下:
包路径:org.apache.poi.hssf.usermodel.HSSFFont
类名称:HSSFFont
方法名:setFontName
[英]set the name for the font (i.e. Arial)
[中]设置字体的名称(即Arial)
代码示例来源:origin: org.apache.poi/poi
private HSSFFont matchFont( Font matchFont )
{
HSSFColor hssfColor = workbook.getCustomPalette()
.findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
if (hssfColor == null)
hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
boolean bold = (matchFont.getStyle() & Font.BOLD) != 0;
boolean italic = (matchFont.getStyle() & Font.ITALIC) != 0;
HSSFFont hssfFont = workbook.findFont(bold,
hssfColor.getIndex(),
(short)(matchFont.getSize() * 20),
matchFont.getName(),
italic,
false,
(short)0,
(byte)0);
if (hssfFont == null)
{
hssfFont = workbook.createFont();
hssfFont.setBold(bold);
hssfFont.setColor(hssfColor.getIndex());
hssfFont.setFontHeight((short)(matchFont.getSize() * 20));
hssfFont.setFontName(matchFont.getName());
hssfFont.setItalic(italic);
hssfFont.setStrikeout(false);
hssfFont.setTypeOffset((short) 0);
hssfFont.setUnderline((byte) 0);
}
return hssfFont;
}
代码示例来源:origin: stackoverflow.com
HSSFFont hSSFFont = (HSSFFont) workbook.createFont();
hSSFFont.setFontName(HSSFFont.FONT_ARIAL);
hSSFFont.setCharSet(HSSFFont.ANSI_CHARSET);
代码示例来源:origin: stackoverflow.com
HSSFCellStyle cellStyle = workBook.createCellStyle();
HSSFFont font = wb.createFont();
font.setFontName(XSSFFont.DEFAULT_FONT_NAME);
font.setFontHeightInPoints((short)10);
font.setColor(IndexedColors.BLUE.getIndex());
cellStyle.setFont(font);
//the version i am using is poi-3.8
代码示例来源: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: com.haulmont.thirdparty/poi
private HSSFFont matchFont( Font font )
{
HSSFColor hssfColor = workbook.getCustomPalette()
.findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
if (hssfColor == null)
hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
boolean bold = (font.getStyle() & Font.BOLD) != 0;
boolean italic = (font.getStyle() & Font.ITALIC) != 0;
HSSFFont hssfFont = workbook.findFont(bold ? HSSFFont.BOLDWEIGHT_BOLD : 0,
hssfColor.getIndex(),
(short)(font.getSize() * 20),
font.getName(),
italic,
false,
(short)0,
(byte)0);
if (hssfFont == null)
{
hssfFont = workbook.createFont();
hssfFont.setBoldweight(bold ? HSSFFont.BOLDWEIGHT_BOLD : 0);
hssfFont.setColor(hssfColor.getIndex());
hssfFont.setFontHeight((short)(font.getSize() * 20));
hssfFont.setFontName(font.getName());
hssfFont.setItalic(italic);
hssfFont.setStrikeout(false);
hssfFont.setTypeOffset((short) 0);
hssfFont.setUnderline((byte) 0);
}
return hssfFont;
}
代码示例来源:origin: stackoverflow.com
my_font.setFontName("Verdana");
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
private HSSFFont matchFont( Font matchFont )
{
HSSFColor hssfColor = workbook.getCustomPalette()
.findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
if (hssfColor == null)
hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
boolean bold = (matchFont.getStyle() & Font.BOLD) != 0;
boolean italic = (matchFont.getStyle() & Font.ITALIC) != 0;
HSSFFont hssfFont = workbook.findFont(bold,
hssfColor.getIndex(),
(short)(matchFont.getSize() * 20),
matchFont.getName(),
italic,
false,
(short)0,
(byte)0);
if (hssfFont == null)
{
hssfFont = workbook.createFont();
hssfFont.setBold(bold);
hssfFont.setColor(hssfColor.getIndex());
hssfFont.setFontHeight((short)(matchFont.getSize() * 20));
hssfFont.setFontName(matchFont.getName());
hssfFont.setItalic(italic);
hssfFont.setStrikeout(false);
hssfFont.setTypeOffset((short) 0);
hssfFont.setUnderline((byte) 0);
}
return hssfFont;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
private HSSFFont matchFont( Font font )
{
HSSFColor hssfColor = workbook.getCustomPalette()
.findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
if (hssfColor == null)
hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
boolean bold = (font.getStyle() & Font.BOLD) != 0;
boolean italic = (font.getStyle() & Font.ITALIC) != 0;
HSSFFont hssfFont = workbook.findFont(bold ? HSSFFont.BOLDWEIGHT_BOLD : 0,
hssfColor.getIndex(),
(short)(font.getSize() * 20),
font.getName(),
italic,
false,
(short)0,
(byte)0);
if (hssfFont == null)
{
hssfFont = workbook.createFont();
hssfFont.setBoldweight(bold ? HSSFFont.BOLDWEIGHT_BOLD : 0);
hssfFont.setColor(hssfColor.getIndex());
hssfFont.setFontHeight((short)(font.getSize() * 20));
hssfFont.setFontName(font.getName());
hssfFont.setItalic(italic);
hssfFont.setStrikeout(false);
hssfFont.setTypeOffset((short) 0);
hssfFont.setUnderline((byte) 0);
}
return hssfFont;
}
代码示例来源: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: 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: stackoverflow.com
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("New sheet");
HSSFFont font = wb.createFont();
font.setFontName("Arial Unicode MS");
HSSFCellStyle style = wb.createCellStyle();
style.setFont(font);
HSSFRow row = sheet.createRow((short) 0);
HSSFCell cell = row.createCell((short) 0);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellStyle(style);
cell.setCellValue("\u53f8");
代码示例来源:origin: youseries/ureport
font.setFontName(fontFamily);
代码示例来源:origin: stackoverflow.com
font.setFontName(HSSFFont.FONT_ARIAL);
font.setFontHeightInPoints((short) 20);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
代码示例来源: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: org.apache.poi/poi-examples
public static void main(String[] args) throws IOException {
try (HSSFWorkbook wb = new HSSFWorkbook()) {
HSSFSheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
HSSFRow row = sheet.createRow(1);
// Create a new font and alter it.
HSSFFont 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.
HSSFCellStyle style = wb.createCellStyle();
style.setFont(font);
// Create a cell and put a value in it.
HSSFCell cell = row.createCell(1);
cell.setCellValue("This is a test of fonts");
cell.setCellStyle(style);
// Write the output to a file
try (FileOutputStream fileOut = new FileOutputStream("workbook.xls")) {
wb.write(fileOut);
}
}
}
}
代码示例来源:origin: stackoverflow.com
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("FirstSheet");
HSSFRow rowhead = sheet.createRow(0);
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setFontName(HSSFFont.FONT_ARIAL);
font.setFontHeightInPoints((short)10);
font.setBold(true);
style.setFont(font);
rowhead.createCell(0).setCellValue("ID");
rowhead.createCell(1).setCellValue("First");
rowhead.createCell(2).setCellValue("Second");
rowhead.createCell(3).setCellValue("Third");
for(int j = 0; j<=3; j++)
rowhead.getCell(j).setCellStyle(style);
代码示例来源: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: lanyuancom/lanyuan-2.0
font.setFontName("宋体");
if(position_title.equals(position)){
font.setFontHeightInPoints((short)11);
内容来源于网络,如有侵权,请联系作者删除!