本文整理匯總了Java中org.apache.poi.ss.usermodel.Workbook.createFont方法的典型用法代碼示例。如果您正苦於以下問題:Java Workbook.createFont方法的具體用法?Java Workbook.createFont怎麽用?Java Workbook.createFont使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.ss.usermodel.Workbook
的用法示例。
在下文中一共展示了Workbook.createFont方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createIndentationCellStyle
import org.apache.poi.ss.usermodel.Workbook; //導入方法依賴的package包/類
public CellStyle createIndentationCellStyle(Workbook workbook, int s) {
CellStyle dataStyle1 = this.createBorderCellStyle(workbook, true);
Font dataFont = workbook.createFont();
dataFont.setColor((short) 12);
dataFont.setFontHeightInPoints((short) 10);
dataStyle1.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dataStyle1.setFillForegroundColor((short) 11);
dataStyle1.setFont(dataFont);
dataStyle1.setVerticalAlignment(VerticalAlignment.CENTER);
dataStyle1.setAlignment(HorizontalAlignment.LEFT);
dataStyle1.setIndention(Short.valueOf(String.valueOf((s))));
return dataStyle1;
}
示例2: defaultHeaderCellStyle
import org.apache.poi.ss.usermodel.Workbook; //導入方法依賴的package包/類
/**
* Returns the default header style. Obtained from:
* http://svn.apache.org/repos/asf/poi
* /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
*
* @param wb the wb
* @return the cell style
*/
protected CellStyle defaultHeaderCellStyle(final Workbook wb) {
CellStyle style;
final Font monthFont = wb.createFont();
monthFont.setFontHeightInPoints((short) 11);
monthFont.setColor(IndexedColors.WHITE.getIndex());
style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setFont(monthFont);
style.setWrapText(true);
return style;
}
示例3: doCreateCellStyle
import org.apache.poi.ss.usermodel.Workbook; //導入方法依賴的package包/類
/** 創建每個CellStyle,並放到map之中
* @param workbook
* @param styleInfo
* @param dataFormat
* @return
*/
public static CellStyle doCreateCellStyle(Workbook workbook,ExportCellStyleInfo styleInfo,String dataFormat) {
if(styleInfo != null ){
CellStyle cellStyle = workbook.createCellStyle();
setStyleValue(ExportCellStyleInfo.class, cellStyle, styleInfo);
if(styleInfo.getFontStyleInfo() != null){
Font fontStyle = workbook.createFont();
setStyleValue(ExportFontStyleInfo.class, fontStyle, styleInfo.getFontStyleInfo());
cellStyle.setFont(fontStyle);
}
if(!StringUtils.isEmpty(dataFormat)){
short format = workbook.createDataFormat().getFormat(dataFormat);
cellStyle.setDataFormat(format);
}
return cellStyle;
}
return null;
}
示例4: defaultTitleCellStyle
import org.apache.poi.ss.usermodel.Workbook; //導入方法依賴的package包/類
/**
* Returns the default title style. Obtained from:
* http://svn.apache.org/repos/asf/poi
* /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
*
* @param wb the wb
* @return the cell style
*/
protected CellStyle defaultTitleCellStyle(final Workbook wb) {
CellStyle style;
final Font titleFont = wb.createFont();
titleFont.setFontHeightInPoints((short) 18);
titleFont.setBold(true);
style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFont(titleFont);
return style;
}
示例5: setCellStyleFont
import org.apache.poi.ss.usermodel.Workbook; //導入方法依賴的package包/類
public void setCellStyleFont(Workbook workbook, CellStyle style, int i) {
Font font = workbook.createFont();
if (i == 0) {
// 正常
} else if (i == 4) {
// 下劃線
font.setUnderline(Font.U_SINGLE);
style.setFont(font);
} else if (i == 2) {
// 傾斜
font.setItalic(true);
style.setFont(font);
} else if (i == 1) {
// 加粗
font.setBold(true);
style.setFont(font);
}
}
示例6: createStyles
import org.apache.poi.ss.usermodel.Workbook; //導入方法依賴的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;
}
示例7: createStyles
import org.apache.poi.ss.usermodel.Workbook; //導入方法依賴的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: createCellStyle
import org.apache.poi.ss.usermodel.Workbook; //導入方法依賴的package包/類
private static XSSFCellStyle createCellStyle(Workbook workbook) {
XSSFCellStyle xstyle = (XSSFCellStyle) workbook.createCellStyle();
XSSFFont font = (XSSFFont) workbook.createFont();
font.setFontHeightInPoints((short) 11);
xstyle.setFont(font);
return xstyle;
}
示例9: initializeSheet
import org.apache.poi.ss.usermodel.Workbook; //導入方法依賴的package包/類
private static CellStyle initializeSheet(Workbook wb, Sheet sheet) {
PrintSetup printSetup = sheet.getPrintSetup();
printSetup.setLandscape(true);
sheet.setFitToPage(true);
sheet.setHorizontallyCenter(true);
CellStyle styleTitle;
Font titleFont = wb.createFont();
titleFont.setFontHeightInPoints((short) 12);
titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
titleFont.setFontName("Arial");
styleTitle = wb.createCellStyle();
styleTitle.setFont(titleFont);
return styleTitle;
}
示例10: builder
import org.apache.poi.ss.usermodel.Workbook; //導入方法依賴的package包/類
/**
* 構建ExcelStyle
*
* @param workbook
* @return
*/
public static ExcelStyle builder(Workbook workbook) {
ExcelStyle excelStyle = new ExcelStyle(workbook.createCellStyle(), workbook.createFont());
return excelStyle;
}