Example usage for org.apache.poi.ss.usermodel BorderStyle THIN

List of usage examples for org.apache.poi.ss.usermodel BorderStyle THIN

Introduction

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

Prototype

BorderStyle THIN

To view the source code for org.apache.poi.ss.usermodel BorderStyle THIN.

Click Source Link

Document

Thin border

Usage

From source file:nl.detoren.ijc.io.OutputExcel.java

License:Open Source License

private void borderRight(Cell cell) {
    if (cell != null) {
        Workbook wb = cell.getRow().getSheet().getWorkbook();
        CellStyle style = wb.createCellStyle();
        style.setBorderRight(BorderStyle.THIN);
        cell.setCellStyle(style);/*from   w  w  w  . j  a  v  a2s .  c  o  m*/
    }
}

From source file:nl.detoren.ijc.io.OutputExcel.java

License:Open Source License

private void borderBottom(Cell cell) {
    if (cell != null) {
        Workbook wb = cell.getRow().getSheet().getWorkbook();
        CellStyle style = wb.createCellStyle();
        style.setBorderBottom(BorderStyle.THIN);
        cell.setCellStyle(style);/*from  ww w  .jav a  2  s  . c om*/
    }
}

From source file:nl.detoren.ijc.io.OutputExcel.java

License:Open Source License

private void borderLeftBottom(Cell cell) {
    if (cell != null) {
        Workbook wb = cell.getRow().getSheet().getWorkbook();
        CellStyle style = wb.createCellStyle();
        style.setBorderBottom(BorderStyle.THIN);
        style.setBorderLeft(BorderStyle.THIN);
        cell.setCellStyle(style);/*from w ww.ja  v  a2s  .c  om*/
    }
}

From source file:nl.detoren.ijc.io.OutputExcel.java

License:Open Source License

private void borderRightBottom(Cell cell) {
    if (cell != null) {
        Workbook wb = cell.getRow().getSheet().getWorkbook();
        CellStyle style = wb.createCellStyle();
        style.setBorderBottom(BorderStyle.THIN);
        style.setBorderRight(BorderStyle.THIN);
        cell.setCellStyle(style);/*from w w w  .j a  v a2 s.  c om*/
    }
}

From source file:org.dashbuilder.dataset.service.DataSetExportServicesImpl.java

License:Apache License

private Map<String, CellStyle> createStyles(Workbook wb) {
    Map<String, CellStyle> styles = new HashMap<>();
    CellStyle style;/*from  ww  w.  ja v  a 2s.c o m*/

    Font titleFont = wb.createFont();
    titleFont.setFontHeightInPoints((short) 12);
    titleFont.setBold(true);
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setFont(titleFont);
    style.setWrapText(false);
    style.setBorderBottom(BorderStyle.THIN);
    style.setBottomBorderColor(IndexedColors.GREY_80_PERCENT.getIndex());
    styles.put("header", style);

    Font cellFont = wb.createFont();
    cellFont.setFontHeightInPoints((short) 10);
    cellFont.setBold(true);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.RIGHT);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat(wb.createDataFormat().getFormat(BuiltinFormats.getBuiltinFormat(3)));
    styles.put("integer_number_cell", style);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.RIGHT);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat(wb.createDataFormat().getFormat(BuiltinFormats.getBuiltinFormat(4)));
    styles.put("decimal_number_cell", style);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.LEFT);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat((short) BuiltinFormats.getBuiltinFormat("text"));
    styles.put(TEXT_CELL, style);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat(wb.createDataFormat()
            .getFormat(DateFormatConverter.convert(Locale.getDefault(), dateFormatPattern)));
    styles.put("date_cell", style);
    return styles;
}

From source file:org.haplo.jsinterface.generate.KGenerateXLS.java

License:Mozilla Public License

@Override
protected void writeRow(int rowNumber, ArrayList<Object> row, ArrayList<Object> rowOptions, boolean isHeaderRow,
        boolean pageBreakBefore) {
    Row r = this.sheet.createRow(rowNumber);

    if (pageBreakBefore && rowNumber > 0) {
        this.sheet.setRowBreak(rowNumber - 1);
    }//  w  w  w  .  j  a v  a 2s  .c  o  m

    int rowSize = row.size();
    for (int i = 0; i < rowSize; ++i) {
        Object value = row.get(i); // ConsString is checked
        if (value != null) {
            Cell c = r.createCell(i);
            if (value instanceof Number) {
                c.setCellValue(((Number) value).doubleValue());
            } else if (value instanceof CharSequence) {
                c.setCellValue(((CharSequence) value).toString());
            } else if (value instanceof Date) {
                c.setCellValue((Date) value);
                // Check to see if option is for dates only
                boolean dateAndTimeStyle = true;
                String options = (String) getOptionsFromArrayList(rowOptions, i, String.class); // ConsString is checked by getOptionsFromArrayList()
                if (options != null && options.equals("date")) {
                    dateAndTimeStyle = false;
                }
                if (dateCellStyle == null) {
                    // Only create one each of the date cell styles per workbook to save space.
                    dateCellStyle = workbook.createCellStyle();
                    dateCellStyle.setDataFormat(workbook.createDataFormat().getFormat("yyyy-mm-dd hh:mm"));
                    dateOnlyCellStyle = workbook.createCellStyle();
                    dateOnlyCellStyle.setDataFormat(workbook.createDataFormat().getFormat("yyyy-mm-dd"));
                }
                c.setCellStyle(dateAndTimeStyle ? dateCellStyle : dateOnlyCellStyle);
                // Set column width so the dates don't come out as ########## on causal viewing
                setMinimumWidth(i, dateAndTimeStyle ? DATE_AND_TIME_COLUMN_WIDTH : DATE_COLUMN_WIDTH);
            }
        }
    }

    if (isHeaderRow) {
        // Make sure the row is always on screen
        this.sheet.createFreezePane(0, 1, 0, 1);
        // Style the row
        CellStyle style = this.workbook.createCellStyle();
        style.setBorderBottom(BorderStyle.THIN);
        Font font = this.workbook.createFont();
        font.setBold(true);
        style.setFont(font);
        r.setRowStyle(style);
        // Style the cells
        for (int s = 0; s < rowSize; ++s) {
            Cell c = r.getCell(s);
            if (c == null) {
                c = r.createCell(s);
            }
            c.setCellStyle(style);
        }
    }
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.xls.helper.HSSFCellStyleProducer.java

License:Open Source License

/**
 * Tries to translate the given stroke width into one of the predefined excel border styles.
 *
 * @param widthRaw the AWT-Stroke-Width.
 * @return the translated excel border width.
 *//*from   ww w  .ja  va 2  s.  c  om*/
protected static org.apache.poi.ss.usermodel.BorderStyle translateStroke(
        final org.pentaho.reporting.engine.classic.core.style.BorderStyle borderStyle, final long widthRaw) {
    final double width = StrictGeomUtility.toExternalValue(widthRaw);

    if (org.pentaho.reporting.engine.classic.core.style.BorderStyle.NONE.equals(borderStyle)) {
        return BorderStyle.NONE;
    } else if (org.pentaho.reporting.engine.classic.core.style.BorderStyle.DASHED.equals(borderStyle)) {
        return width <= 1.5 ? BorderStyle.DASHED : BorderStyle.MEDIUM_DASHED;
    } else if (org.pentaho.reporting.engine.classic.core.style.BorderStyle.DOT_DOT_DASH.equals(borderStyle)) {
        return width <= 1.5 ? BorderStyle.DASH_DOT_DOT : BorderStyle.MEDIUM_DASH_DOT_DOT;
    } else if (org.pentaho.reporting.engine.classic.core.style.BorderStyle.DOT_DASH.equals(borderStyle)) {
        return width <= 1.5 ? BorderStyle.DASH_DOT : BorderStyle.MEDIUM_DASH_DOT;
    } else if (org.pentaho.reporting.engine.classic.core.style.BorderStyle.DOTTED.equals(borderStyle)) {
        return BorderStyle.DOTTED;
    } else if (org.pentaho.reporting.engine.classic.core.style.BorderStyle.DOUBLE.equals(borderStyle)) {
        return BorderStyle.DOUBLE;
    } else if (width == 0) {
        return BorderStyle.NONE;
    } else if (width <= 0.5) {
        return BorderStyle.HAIR;
    } else if (width <= 1) {
        return BorderStyle.THIN;
    } else if (width <= 1.5) {
        return BorderStyle.MEDIUM;
    } else {
        return BorderStyle.THICK;
    }
}

From source file:org.sysmodb.xml.XMLStyleGenerator.java

License:BSD License

private static Map<BorderStyle, String> createBorderMap() {
    Map<BorderStyle, String> result = new HashMap<BorderStyle, String>();
    result.put(BorderStyle.DASHED, "dashed 1pt");
    result.put(BorderStyle.DASH_DOT, "dashed 1pt");
    result.put(BorderStyle.DASH_DOT_DOT, "dashed 1pt");
    result.put(BorderStyle.DOTTED, "dotted 1pt");
    result.put(BorderStyle.DOUBLE, "double 3pt");
    result.put(BorderStyle.HAIR, "solid 1pt");
    result.put(BorderStyle.MEDIUM, "2pt solid");
    result.put(BorderStyle.MEDIUM_DASHED, "2pt dashed");
    result.put(BorderStyle.MEDIUM_DASH_DOT, "2pt dashed");
    result.put(BorderStyle.MEDIUM_DASH_DOT_DOT, "2pt dashed");
    result.put(BorderStyle.NONE, "none");
    result.put(BorderStyle.SLANTED_DASH_DOT, "dashed 2pt");
    result.put(BorderStyle.THICK, "solid 3pt");
    result.put(BorderStyle.THIN, "dashed 1pt");

    return Collections.unmodifiableMap(result);
}

From source file:org.unitime.timetable.export.XLSPrinter.java

License:Apache License

public XLSPrinter(OutputStream output, boolean checkLast) {
    iOutput = output;//ww w  .  j  ava  2  s .co  m
    iCheckLast = checkLast;
    iWorkbook = new HSSFWorkbook();
    iSheet = iWorkbook.createSheet();
    iSheet.setDisplayGridlines(false);
    iSheet.setPrintGridlines(false);
    iSheet.setFitToPage(true);
    iSheet.setHorizontallyCenter(true);
    PrintSetup printSetup = iSheet.getPrintSetup();
    printSetup.setLandscape(true);
    iSheet.setAutobreaks(true);
    printSetup.setFitHeight((short) 1);
    printSetup.setFitWidth((short) 1);
    iStyles = new HashMap<String, CellStyle>();

    CellStyle style;

    style = iWorkbook.createCellStyle();
    style.setBorderBottom(BorderStyle.THIN);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    style.setAlignment(HorizontalAlignment.LEFT);
    style.setVerticalAlignment(VerticalAlignment.TOP);
    style.setFont(getFont(true, false, false, Color.BLACK));
    style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setWrapText(true);
    iStyles.put("header", style);

    style = iWorkbook.createCellStyle();
    style.setAlignment(HorizontalAlignment.LEFT);
    style.setVerticalAlignment(VerticalAlignment.TOP);
    style.setFont(getFont(false, false, false, Color.BLACK));
    style.setWrapText(true);
    iStyles.put("plain", style);

    style = iWorkbook.createCellStyle();
    style.setAlignment(HorizontalAlignment.RIGHT);
    style.setVerticalAlignment(VerticalAlignment.TOP);
    style.setFont(getFont(false, false, false, Color.BLACK));
    iStyles.put("number", style);
}

From source file:org.zafritech.zidingorms.io.excel.ExcelFunctions.java

private static CellStyle createBorderedStyle(Workbook wb) {

    CellStyle style = wb.createCellStyle();
    style.setBorderRight(BorderStyle.THIN);
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderBottom(BorderStyle.THIN);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderLeft(BorderStyle.THIN);
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderTop(BorderStyle.THIN);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());

    return style;
}