Example usage for org.apache.poi.ss.usermodel FillPatternType FINE_DOTS

List of usage examples for org.apache.poi.ss.usermodel FillPatternType FINE_DOTS

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel FillPatternType FINE_DOTS.

Prototype

FillPatternType FINE_DOTS

To view the source code for org.apache.poi.ss.usermodel FillPatternType FINE_DOTS.

Click Source Link

Document

Small fine dots

Usage

From source file:de.viaboxx.nlstools.formats.MBExcelPersistencer.java

License:Apache License

private void initStyles(HSSFWorkbook wb) {
    // cache styles used to write text into cells
    HSSFCellStyle style = wb.createCellStyle();
    HSSFFont font = wb.createFont();/*from   w  ww . j  a va  2 s.  co m*/
    font.setBold(true);
    style.setFont(font);
    styles.put(STYLE_BOLD, style);

    style = wb.createCellStyle();
    font = wb.createFont();
    font.setItalic(true);
    style.setFont(font);
    styles.put(STYLE_ITALIC, style);

    style = wb.createCellStyle();
    font = wb.createFont();
    font.setItalic(true);
    font.setColor(Font.COLOR_RED);
    style.setFont(font);
    styles.put(STYLE_REVIEW, style);

    style = wb.createCellStyle();
    style.setFillPattern(FillPatternType.FINE_DOTS);
    style.setFillBackgroundColor(HSSFColor.HSSFColorPredefined.BLUE_GREY.getIndex());
    style.setFillForegroundColor(HSSFColor.HSSFColorPredefined.BLUE_GREY.getIndex());
    styles.put(STYLE_MISSING, style);

    style = wb.createCellStyle();
    style.setFillPattern(FillPatternType.FINE_DOTS);
    style.setFillBackgroundColor(HSSFColor.HSSFColorPredefined.BLUE_GREY.getIndex());
    style.setFillForegroundColor(HSSFColor.HSSFColorPredefined.BLUE_GREY.getIndex());
    style.setFont(font);
    styles.put(STYLE_MISSING_REVIEW, style);

    style = wb.createCellStyle();
    HSSFCreationHelper createHelper = wb.getCreationHelper();
    style.setDataFormat(createHelper.createDataFormat().getFormat("yyyy-dd-mm hh:mm"));
    styles.put(STYLE_DATETIME, style);
}

From source file:org.pentaho.di.trans.steps.excelwriter.ExcelWriterStep_StyleFormatTest.java

License:Apache License

/**
 * Setup the data necessary for Excel Writer step
 *
 * @param fileType// w  ww  .  j a  va  2 s  .c o m
 * @throws KettleException
 */
private void createStepData(String fileType) throws KettleException {
    stepData = new ExcelWriterStepData();
    stepData.inputRowMeta = step.getInputRowMeta().clone();
    stepData.outputRowMeta = step.getInputRowMeta().clone();

    // we don't run transformation so ExcelWriterStep.processRow() doesn't get executed
    // we populate the ExcelWriterStepData with bare minimum required values
    CellReference cellRef = new CellReference(stepMeta.getStartingCell());
    stepData.startingRow = cellRef.getRow();
    stepData.startingCol = cellRef.getCol();
    stepData.posX = stepData.startingCol;
    stepData.posY = stepData.startingRow;

    int numOfFields = stepData.inputRowMeta.size();
    stepData.fieldnrs = new int[numOfFields];
    stepData.linkfieldnrs = new int[numOfFields];
    stepData.commentfieldnrs = new int[numOfFields];
    for (int i = 0; i < numOfFields; i++) {
        stepData.fieldnrs[i] = i;
        stepData.linkfieldnrs[i] = -1;
        stepData.commentfieldnrs[i] = -1;
    }

    // we avoid reading/writing Excel files, so ExcelWriterStep.prepareNextOutputFile() doesn't get executed
    // create Excel workbook object
    stepData.wb = stepMeta.getExtension().equalsIgnoreCase("xlsx") ? new XSSFWorkbook() : new HSSFWorkbook();
    stepData.sheet = stepData.wb.createSheet();
    stepData.file = null;
    stepData.clearStyleCache(numOfFields);

    // we avoid reading template file from disk
    // so set beforehand cells with custom style and formatting
    DataFormat format = stepData.wb.createDataFormat();
    Row xlsRow = stepData.sheet.createRow(0);

    // Cell F1 has custom style applied, used as template
    Cell cell = xlsRow.createCell(5);
    CellStyle cellStyle = stepData.wb.createCellStyle();
    cellStyle.setBorderRight(BorderStyle.THICK);
    cellStyle.setFillPattern(FillPatternType.FINE_DOTS);
    cell.setCellStyle(cellStyle);

    // Cell G1 has same style, but also a custom data format
    cellStyle = stepData.wb.createCellStyle();
    cellStyle.cloneStyleFrom(cell.getCellStyle());
    cell = xlsRow.createCell(6);
    cellStyle.setDataFormat(format.getFormat("##0,000.0"));
    cell.setCellStyle(cellStyle);
}