本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFFont.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java HSSFFont.setColor方法的具体用法?Java HSSFFont.setColor怎么用?Java HSSFFont.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.hssf.usermodel.HSSFFont
的用法示例。
在下文中一共展示了HSSFFont.setColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHSSFCellStyle
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
private HSSFCellStyle createHSSFCellStyle(Workbook wb, int[] bgColor, int[] fontColor, int fontSize) {
HSSFWorkbook workbook = (HSSFWorkbook) wb;
HSSFPalette palette = workbook.getCustomPalette();
palette.setColorAtIndex((short) 9, (byte) fontColor[0], (byte) fontColor[1], (byte) fontColor[2]);
palette.setColorAtIndex((short) 10, (byte) bgColor[0], (byte) bgColor[1], (byte) bgColor[2]);
HSSFFont titleFont = workbook.createFont();
titleFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
titleFont.setFontName("宋体");
titleFont.setColor((short) 9);
titleFont.setBold(true);
titleFont.setFontHeightInPoints((short) fontSize);
HSSFCellStyle titleStyle = (HSSFCellStyle) createBorderCellStyle(workbook, true);
titleStyle.setFont(titleFont);
titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
titleStyle.setFillForegroundColor((short) 10);
titleStyle.setAlignment(HorizontalAlignment.CENTER);
titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
return titleStyle;
}
示例2: createCellStyleForColumnHeading
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
public static HSSFCellStyle createCellStyleForColumnHeading(HSSFWorkbook workBook) {
HSSFCellStyle cellStyle = workBook.createCellStyle();
HSSFFont fontObj = workBook.createFont();
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setWrapText(true);
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setFillBackgroundColor(Short.valueOf("22").shortValue());
cellStyle.setFillPattern(FillPatternType.BIG_SPOTS);
cellStyle.setFillForegroundColor(Short.valueOf("22").shortValue());
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
fontObj.setFontName("Calibri");
fontObj.setFontHeightInPoints(Short.valueOf("12").shortValue());
fontObj.setBold(true);
fontObj.setColor(Short.valueOf("8").shortValue());
cellStyle.setFont(fontObj);
return cellStyle;
}
示例3: estiloCabecalho
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
/**
* Estilo de cabecalho.
* @param wb
* @return retorna o estilo da celula.
* @author Ekler Paulino de Mattos.
*/
private HSSFCellStyle estiloCabecalho(HSSFWorkbook wb){
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THICK);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THICK);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THICK);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THICK);
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
// cellStyle.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index);
cellStyle.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFFont font = cellStyle.getFont(wb);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setColor(HSSFFont.COLOR_NORMAL);
font.setFontName(HSSFFont.FONT_ARIAL);
cellStyle.setFont(font);
return cellStyle;
}
示例4: estiloDadosConsultado
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
/**
* Estilo dos campos dos dados.
* @param wb
* @return retorna o estilo da celula.
* @author Ekler Paulino de Mattos.
*/
private HSSFCellStyle estiloDadosConsultado(HSSFWorkbook wb){
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
// plano de fundo - para que funcione deve se
// definido antes um padrao de preenchimento.
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
//cellStyle.setFillForegroundColor(HSSFColor.AQUA.index);
cellStyle.setFillForegroundColor(HSSFColor.WHITE.index);
cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFFont font = cellStyle.getFont(wb);
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
font.setColor(HSSFFont.COLOR_NORMAL);
font.setFontName(HSSFFont.FONT_ARIAL);
cellStyle.setFont(font);
return cellStyle;
}
示例5: estiloDadosRetorno
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
/**
* Estilo dos campos dos dados.
* @param wb
* @return retorna o estilo da celula.
* @author Ekler Paulino de Mattos.
*/
private HSSFCellStyle estiloDadosRetorno(HSSFWorkbook wb){
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
// plano de fundo - para que funcione deve se
// definido antes um padrao de preenchimento.
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
//cellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
cellStyle.setFillForegroundColor(HSSFColor.PALE_BLUE.index);
cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFFont font = cellStyle.getFont(wb);
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
font.setColor(HSSFFont.COLOR_NORMAL);
font.setFontName(HSSFFont.FONT_ARIAL);
cellStyle.setFont(font);
return cellStyle;
}
示例6: estiloCabecalho
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
/**
* Estilo de cabecalho.
* @param wb
* @return retorna o estilo da celula.
* @author Ekler Paulino de Mattos.
*/
private HSSFCellStyle estiloCabecalho(HSSFWorkbook wb){
if(this.estiloCabecalho==null){
this.estiloCabecalho = wb.createCellStyle();
this.estiloCabecalho.setBorderBottom(HSSFCellStyle.BORDER_THIN);
this.estiloCabecalho.setBorderRight(HSSFCellStyle.BORDER_THIN);
this.estiloCabecalho.setBorderLeft(HSSFCellStyle.BORDER_THIN);
this.estiloCabecalho.setBorderTop(HSSFCellStyle.BORDER_THIN);
this.estiloCabecalho.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
// cellStyle.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index);
this.estiloCabecalho.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
this.estiloCabecalho.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFFont font = this.estiloCabecalho.getFont(wb);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setColor(HSSFFont.COLOR_NORMAL);
font.setFontName(HSSFFont.FONT_ARIAL);
this.estiloCabecalho.setFont(font);
}
return this.estiloCabecalho;
}
示例7: addColourToFont
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
@Override
public void addColourToFont(Workbook workbook, Font font, String colour) {
if(colour == null) {
return ;
}
if(IStyle.TRANSPARENT_VALUE.equals(colour)) {
return ;
}
if(font instanceof HSSFFont) {
HSSFFont hFont = (HSSFFont)font;
short colourIndex = getHColour((HSSFWorkbook)workbook, colour);
if( colourIndex > 0 ) {
hFont.setColor(colourIndex);
}
}
}
示例8: setHeaderStyle
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
private void setHeaderStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 8);
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
style.setWrapText(true);
headerStyle = style;
}
示例9: setVerticalHeaderStyle
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
private void setVerticalHeaderStyle(HSSFWorkbook wb) {
verticalHeaderStyle = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 8);
verticalHeaderStyle.setFont(font);
verticalHeaderStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
verticalHeaderStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
verticalHeaderStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
verticalHeaderStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
verticalHeaderStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
verticalHeaderStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
verticalHeaderStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
verticalHeaderStyle.setRotation((short) 90);
}
示例10: setDoubleNegativeStyle
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
private void setDoubleNegativeStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setFontHeightInPoints((short) 8);
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
style.setDataFormat(wb.createDataFormat().getFormat("#,##0.00"));
font.setColor(HSSFColor.RED.index);
doubleNegativeStyle = style;
}
示例11: createHeader
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
private void createHeader(
HSSFWorkbook wb,
HSSFSheet sheet,
List<TascaDadaDto> informeCamps) {
HSSFFont bold;
bold = wb.createFont();
bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
bold.setColor(HSSFColor.WHITE.index);
HSSFCellStyle headerStyle;
headerStyle = wb.createCellStyle();
headerStyle.setFillPattern(HSSFCellStyle.FINE_DOTS);
headerStyle.setFillBackgroundColor(HSSFColor.GREY_80_PERCENT.index);
headerStyle.setFont(bold);
int rowNum = 0;
int colNum = 0;
// Capçalera
HSSFRow xlsRow = sheet.createRow(rowNum++);
HSSFCell cell;
cell = xlsRow.createCell(colNum++);
cell.setCellValue(new HSSFRichTextString(StringUtils.capitalize("Expedient")));
cell.setCellStyle(headerStyle);
for (TascaDadaDto camp : informeCamps) {
sheet.autoSizeColumn(colNum);
cell = xlsRow.createCell(colNum++);
cell.setCellValue(new HSSFRichTextString(StringUtils.capitalize(camp.getCampEtiqueta())));
cell.setCellStyle(headerStyle);
}
}
示例12: createCellStyleForComRepNotSetUp
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
public static HSSFCellStyle createCellStyleForComRepNotSetUp(HSSFWorkbook workBook) {
HSSFCellStyle cellStyle = workBook.createCellStyle();
HSSFFont fontObj = workBook.createFont();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
fontObj.setFontName("Calibri");
fontObj.setFontHeightInPoints(Short.valueOf("12").shortValue());
fontObj.setBold(true);
fontObj.setColor((short) 10);
cellStyle.setFont(fontObj);
return cellStyle;
}
示例13: createCellStyleForComRepSetUp
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
public static HSSFCellStyle createCellStyleForComRepSetUp(HSSFWorkbook workBook) {
HSSFCellStyle cellStyle = workBook.createCellStyle();
HSSFFont fontObj = workBook.createFont();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
fontObj.setFontName("Calibri");
fontObj.setFontHeightInPoints(Short.valueOf("12").shortValue());
fontObj.setBold(true);
fontObj.setColor((short) 17);
cellStyle.setFont(fontObj);
return cellStyle;
}
示例14: generateHeaderStyle
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
/**
* Description: 生成表格的 头部的单元格样式
* @param workbook
* @return
*
* @History
* 1. 2014-12-19 linwb 创建方法
*/
private HSSFCellStyle generateHeaderStyle(HSSFWorkbook workbook) {
//生成表格头部标题栏样式
HSSFCellStyle headerStyle = workbook.createCellStyle();
// 设置这些样式
headerStyle.setFillForegroundColor(headerCellBackgroundColor);
headerStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
headerStyle.setBorderBottom(headerBorderBottom);
headerStyle.setBorderLeft(headerBorderLeft);
headerStyle.setBorderRight(headerBorderRight);
headerStyle.setBorderTop(headerBorderTop);
headerStyle.setAlignment(headerCellTextAlign);
headerStyle.setVerticalAlignment(headerCellVehicleAlign);
// 生成字体
HSSFFont font = workbook.createFont();
font.setColor(headerFontColor);
font.setFontHeightInPoints(headerFontHeight);
font.setBoldweight(headerFontWeight);
// 把字体应用到当前的样式
headerStyle.setFont(font);
return headerStyle;
}
示例15: estiloDadosConsultado
import org.apache.poi.hssf.usermodel.HSSFFont; //导入方法依赖的package包/类
/**
* Estilo dos campos dos dados.
* @param wb
* @return retorna o estilo da celula.
* @author Ekler Paulino de Mattos.
*/
private HSSFCellStyle estiloDadosConsultado(HSSFWorkbook wb){
if(this.estiloDadoConsultado==null){
this.estiloDadoConsultado = wb.createCellStyle();
this.estiloDadoConsultado.setBorderBottom(HSSFCellStyle.BORDER_THIN);
this.estiloDadoConsultado.setBorderRight(HSSFCellStyle.BORDER_THIN);
this.estiloDadoConsultado.setBorderLeft(HSSFCellStyle.BORDER_THIN);
this.estiloDadoConsultado.setBorderTop(HSSFCellStyle.BORDER_THIN);
// plano de fundo - para que funcione deve se
// definido antes um padrao de preenchimento.
this.estiloDadoConsultado.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
//cellStyle.setFillForegroundColor(HSSFColor.AQUA.index);
this.estiloDadoConsultado.setFillForegroundColor(HSSFColor.WHITE.index);
this.estiloDadoConsultado.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFFont font = this.estiloDadoConsultado.getFont(wb);
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
font.setColor(HSSFFont.COLOR_NORMAL);
font.setFontName(HSSFFont.FONT_ARIAL);
this.estiloDadoConsultado.setFont(font);
}
return this.estiloDadoConsultado;
}