org.apache.poi.ss.usermodel.CellStyle.setFillPattern()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(293)

本文整理了Java中org.apache.poi.ss.usermodel.CellStyle.setFillPattern()方法的一些代码示例,展示了CellStyle.setFillPattern()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CellStyle.setFillPattern()方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.CellStyle
类名称:CellStyle
方法名:setFillPattern

CellStyle.setFillPattern介绍

[英]setting to one fills the cell with the foreground color... No idea about other values
[中]设置为1将使用前景颜色填充单元格。。。不知道其他的价值观

代码示例

代码示例来源:origin: looly/hutool

/**
 * 给cell设置颜色
 * 
 * @param cellStyle {@link CellStyle}
 * @param color 背景颜色
 * @param fillPattern 填充方式 {@link FillPatternType}枚举
 * @return {@link CellStyle}
 */
public static CellStyle setColor(CellStyle cellStyle, short color, FillPatternType fillPattern) {
  cellStyle.setFillForegroundColor(color);
  cellStyle.setFillPattern(fillPattern);
  return cellStyle;
}

代码示例来源:origin: looly/hutool

/**
 * 给cell设置颜色
 * 
 * @param cellStyle {@link CellStyle}
 * @param color 背景颜色
 * @param fillPattern 填充方式 {@link FillPatternType}枚举
 * @return {@link CellStyle}
 */
public static CellStyle setColor(CellStyle cellStyle, short color, FillPatternType fillPattern) {
  cellStyle.setFillForegroundColor(color);
  cellStyle.setFillPattern(fillPattern);
  return cellStyle;
}

代码示例来源:origin: stackoverflow.com

// Aqua background
CellStyle style = wb.createCellStyle();
style.setFillBackgroundColor(IndexedColors.AQUA.getIndex());
style.setFillPattern(CellStyle.BIG_SPOTS);
row.setRowStyle(style);

代码示例来源:origin: primefaces/primefaces

HSSFColor backgroundColor = palette.findSimilarColor(color.getRed(), color.getGreen(), color.getBlue());
((HSSFCellStyle) facetStyle).setFillForegroundColor(backgroundColor.getIndex());
facetStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

代码示例来源:origin: primefaces/primefaces

XSSFColor backgroundColor = new XSSFColor(Color.decode(facetBackground));
((XSSFCellStyle) facetStyle).setFillForegroundColor(backgroundColor);
facetStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

代码示例来源:origin: stackoverflow.com

Workbook wb = new XSSFWorkbook("myWorkbook.xlsx");
 Row row=sheet.getRow(0);
 CellStyle style=null;
 XSSFFont defaultFont= wb.createFont();
 defaultFont.setFontHeightInPoints((short)10);
 defaultFont.setFontName("Arial");
 defaultFont.setColor(IndexedColors.BLACK.getIndex());
 defaultFont.setBold(false);
 defaultFont.setItalic(false);
 XSSFFont font= wb.createFont();
 font.setFontHeightInPoints((short)10);
 font.setFontName("Arial");
 font.setColor(IndexedColors.WHITE.getIndex());
 font.setBold(true);
 font.setItalic(false);
 style=row.getRowStyle();
 style.setFillBackgroundColor(IndexedColors.DARK_BLUE.getIndex());
 style.setFillPattern(CellStyle.SOLID_FOREGROUND);
 style.setAlignment(CellStyle.ALIGN_CENTER);
 style.setFont(font);

代码示例来源:origin: alibaba/easyexcel

/**
 *
 * @param workbook
 * @return
 */
public static CellStyle buildDefaultCellStyle(Workbook workbook) {
  CellStyle newCellStyle = workbook.createCellStyle();
  Font font = workbook.createFont();
  font.setFontName("宋体");
  font.setFontHeightInPoints((short)14);
  font.setBold(true);
  newCellStyle.setFont(font);
  newCellStyle.setWrapText(true);
  newCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  newCellStyle.setAlignment(HorizontalAlignment.CENTER);
  newCellStyle.setLocked(true);
  newCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
  newCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
  newCellStyle.setBorderBottom(BorderStyle.THIN);
  newCellStyle.setBorderLeft(BorderStyle.THIN);
  return newCellStyle;
}

代码示例来源:origin: wuyouzhuguli/FEBS-Shiro

@Override
public CellStyle headCellStyle(SXSSFWorkbook wb) {
  CellStyle cellStyle = wb.createCellStyle();
  Font font = wb.createFont();
  cellStyle.setFillForegroundColor((short) 12);
  cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);// 填充模式
  cellStyle.setBorderTop(CellStyle.BORDER_THIN);// 上边框为细边框
  cellStyle.setBorderRight(CellStyle.BORDER_THIN);// 右边框为细边框
  cellStyle.setBorderBottom(CellStyle.BORDER_THIN);// 下边框为细边框
  cellStyle.setBorderLeft(CellStyle.BORDER_THIN);// 左边框为细边框
  cellStyle.setAlignment(CellStyle.ALIGN_LEFT);// 对齐
  cellStyle.setFillForegroundColor(HSSFColor.GREEN.index);
  cellStyle.setFillBackgroundColor(HSSFColor.GREEN.index);
  font.setBoldweight(Font.BOLDWEIGHT_NORMAL);
  // font.setFontHeightInPoints((short) 12);// 字体大小
  font.setColor(HSSFColor.WHITE.index);
  // 应用标题字体到标题样式
  cellStyle.setFont(font);
  return cellStyle;
}

代码示例来源:origin: pentaho/pentaho-kettle

CellStyle cellStyle = stepData.wb.createCellStyle();
cellStyle.setBorderRight( BorderStyle.THICK );
cellStyle.setFillPattern( FillPatternType.FINE_DOTS );
cell.setCellStyle( cellStyle );

代码示例来源:origin: org.apache.poi/poi

/**
 * Sets the format properties of the given style based on the given map.
 *
 * @param style cell style
 * @param workbook parent workbook
 * @param properties map of format properties (String -> Object)
 * @see #getFormatProperties(CellStyle)
 */
private static void setFormatProperties(CellStyle style, Workbook workbook, Map<String, Object> properties) {
  style.setAlignment(getHorizontalAlignment(properties, ALIGNMENT));
  style.setVerticalAlignment(getVerticalAlignment(properties, VERTICAL_ALIGNMENT));
  style.setBorderBottom(getBorderStyle(properties, BORDER_BOTTOM));
  style.setBorderLeft(getBorderStyle(properties, BORDER_LEFT));
  style.setBorderRight(getBorderStyle(properties, BORDER_RIGHT));
  style.setBorderTop(getBorderStyle(properties, BORDER_TOP));
  style.setBottomBorderColor(getShort(properties, BOTTOM_BORDER_COLOR));
  style.setDataFormat(getShort(properties, DATA_FORMAT));
  style.setFillPattern(getFillPattern(properties, FILL_PATTERN));
  style.setFillForegroundColor(getShort(properties, FILL_FOREGROUND_COLOR));
  style.setFillBackgroundColor(getShort(properties, FILL_BACKGROUND_COLOR));
  style.setFont(workbook.getFontAt(getInt(properties, FONT)));
  style.setHidden(getBoolean(properties, HIDDEN));
  style.setIndention(getShort(properties, INDENTION));
  style.setLeftBorderColor(getShort(properties, LEFT_BORDER_COLOR));
  style.setLocked(getBoolean(properties, LOCKED));
  style.setRightBorderColor(getShort(properties, RIGHT_BORDER_COLOR));
  style.setRotation(getShort(properties, ROTATION));
  style.setTopBorderColor(getShort(properties, TOP_BORDER_COLOR));
  style.setWrapText(getBoolean(properties, WRAP_TEXT));
}

代码示例来源:origin: Vatavuk/excel-io

@Override
  public void accept(final CellStyle style) {
    style.setFillPattern(this.pattern);
  }
}

代码示例来源:origin: stackoverflow.com

private static Map<String, CellStyle> styles;

private static Map<String, CellStyle> createStyles(Workbook wb){
    Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
    DataFormat df = wb.createDataFormat();

    CellStyle style;
    Font headerFont = wb.createFont();
    headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    headerFont.setFontHeightInPoints((short) 12);
    style = createBorderedStyle(wb);
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setFont(headerFont);
    styles.put("style1", style);

    style = createBorderedStyle(wb);
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
    style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    style.setFont(headerFont);
    style.setDataFormat(df.getFormat("d-mmm"));
    styles.put("date_style", style);
    ...
    return styles;
  }

代码示例来源:origin: stackoverflow.com

Row row = sheet.createRow(currentRow);

CellStyle style = workbook.createCellStyle();
style.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);

Cell cell = row.createCell(0);
cell.setCellValue("ABCDEFG");
cell.setCellStyle(style);

代码示例来源:origin: top.wboost/common-utils-web

/**
 * 设置文本框属性——标红
 * @param wb Excel工作簿
 * @return CellStyle
 */
private static CellStyle createCellRedStyle(Workbook wb){
  CellStyle style = wb.createCellStyle(); // 样式对象
  style.setFillPattern(CellStyle.SOLID_FOREGROUND);// 设置前景填充样式
  style.setFillForegroundColor(HSSFColor.RED.index);// 前景填充色
  return style;
}

代码示例来源:origin: FenixEdu/fenixedu-academic

private CellStyle headerBackgroundStyle(final HSSFWorkbook wb) {
  CellStyle style = wb.createCellStyle();
  style.setFillBackgroundColor(IndexedColors.AQUA.getIndex());
  style.setFillPattern(FillPatternType.BIG_SPOTS);
  return style;
}

代码示例来源:origin: zhangdaiscott/jeasypoi

@Override
public CellStyle getTitleStyle(short color) {
  CellStyle titleStyle = workbook.createCellStyle();
  titleStyle.setFillForegroundColor(color); // 填充的背景颜色
  titleStyle.setAlignment(CellStyle.ALIGN_CENTER);
  titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
  titleStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); // 填充图案
  titleStyle.setWrapText(true);
  return titleStyle;
}

代码示例来源:origin: cn.afterturn/easypoi-base

@Override
public CellStyle getTitleStyle(short color) {
  CellStyle titleStyle = workbook.createCellStyle();
  titleStyle.setFillForegroundColor(color);
  titleStyle.setAlignment(HorizontalAlignment.CENTER);
  titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
  titleStyle.setWrapText(true);
  return titleStyle;
}

代码示例来源:origin: org.jeecg/easypoi-base

@Override
public CellStyle getTitleStyle(short color) {
  CellStyle titleStyle = workbook.createCellStyle();
  titleStyle.setFillForegroundColor(color); // 填充的背景颜色
  titleStyle.setAlignment(CellStyle.ALIGN_CENTER);
  titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
  titleStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); // 填充图案
  titleStyle.setWrapText(true);
  return titleStyle;
}

代码示例来源:origin: stackoverflow.com

CellStyle backgroundStyle = workbook.createCellStyle();
 backgroundStyle.setFillBackgroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
 backgroundStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
 backgroundStyle.setBorderBottom(CellStyle.BORDER_THIN);
 backgroundStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
 backgroundStyle.setBorderLeft(CellStyle.BORDER_THIN);
 backgroundStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
 backgroundStyle.setBorderRight(CellStyle.BORDER_THIN);
 backgroundStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
 backgroundStyle.setBorderTop(CellStyle.BORDER_THIN);
 backgroundStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());

代码示例来源:origin: stackoverflow.com

CellStyle backgroundStyle = workbook.createCellStyle();
 backgroundStyle.setFillBackgroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
 backgroundStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
 CellStyle borderStyle = workbook.createCellStyle();
 borderStyle.setBorderBottom(CellStyle.BORDER_THIN);
 borderStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
 borderStyle.setBorderLeft(CellStyle.BORDER_THIN);
 borderStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
 borderStyle.setBorderRight(CellStyle.BORDER_THIN);
 borderStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
 borderStyle.setBorderTop(CellStyle.BORDER_THIN);
 borderStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());

相关文章

微信公众号

最新文章

更多