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

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

Introduction

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

Prototype

BorderStyle DASHED

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

Click Source Link

Document

dash border

Usage

From source file:achmad.rifai.admin.ui.Saver.java

private void title(int i, XSSFRow r1, String s) {
    org.apache.poi.xssf.usermodel.XSSFCell c = r1.createCell(i);
    c.setCellType(CellType.STRING);/*from www.  ja  va2s. c  om*/
    c.setCellValue(s);
    org.apache.poi.xssf.usermodel.XSSFCellStyle cs = c.getCellStyle();
    cs.setFillBackgroundColor(new org.apache.poi.xssf.usermodel.XSSFColor(Color.BLACK));
    cs.setFillForegroundColor(new org.apache.poi.xssf.usermodel.XSSFColor(Color.YELLOW));
    cs.setAlignment(HorizontalAlignment.CENTER);
    cs.setVerticalAlignment(VerticalAlignment.CENTER);
    cs.setBorderBottom(BorderStyle.DASHED);
    cs.setBorderTop(BorderStyle.DASHED);
    cs.setBorderLeft(BorderStyle.DASHED);
    cs.setBorderRight(BorderStyle.DASHED);
}

From source file:achmad.rifai.admin.ui.Saver.java

private void konten(int i, XSSFRow r, String s) {
    org.apache.poi.xssf.usermodel.XSSFCell c = r.createCell(i);
    c.setCellType(CellType.STRING);/*from   w w  w .j a v a 2s . c  om*/
    c.setCellValue(s);
    org.apache.poi.xssf.usermodel.XSSFCellStyle cs = c.getCellStyle();
    cs.setFillBackgroundColor(new org.apache.poi.xssf.usermodel.XSSFColor(Color.WHITE));
    cs.setFillForegroundColor(new org.apache.poi.xssf.usermodel.XSSFColor(Color.BLACK));
    cs.setAlignment(HorizontalAlignment.JUSTIFY);
    cs.setVerticalAlignment(VerticalAlignment.TOP);
    cs.setBorderBottom(BorderStyle.DASHED);
    cs.setBorderTop(BorderStyle.DASHED);
    cs.setBorderLeft(BorderStyle.DASHED);
    cs.setBorderRight(BorderStyle.DASHED);
}

From source file:achmad.rifai.admin.ui.Saver.java

private void konten1(int i, XSSFRow r, String s) {
    org.apache.poi.xssf.usermodel.XSSFCell c = r.createCell(i);
    c.setCellType(CellType.STRING);//from  w  w  w  . ja  va2s.c o m
    c.setCellValue(s);
    org.apache.poi.xssf.usermodel.XSSFCellStyle cs = c.getCellStyle();
    cs.setFillBackgroundColor(new org.apache.poi.xssf.usermodel.XSSFColor(Color.WHITE));
    cs.setFillForegroundColor(new org.apache.poi.xssf.usermodel.XSSFColor(Color.BLACK));
    cs.setAlignment(HorizontalAlignment.CENTER);
    cs.setVerticalAlignment(VerticalAlignment.CENTER);
    cs.setBorderBottom(BorderStyle.DASHED);
    cs.setBorderTop(BorderStyle.DASHED);
    cs.setBorderLeft(BorderStyle.DASHED);
    cs.setBorderRight(BorderStyle.DASHED);
}

From source file:achmad.rifai.admin.ui.Saver.java

private void title2(int i, XSSFRow r1, String s, XSSFSheet sh) {
    sh.addMergedRegion(new org.apache.poi.ss.util.CellRangeAddress(0, 1, i, i));
    org.apache.poi.xssf.usermodel.XSSFCell c = r1.createCell(i);
    c.setCellType(CellType.STRING);/*w w  w.j  a  va 2  s . co  m*/
    c.setCellValue(s);
    org.apache.poi.xssf.usermodel.XSSFCellStyle cs = c.getCellStyle();
    cs.setFillBackgroundColor(new org.apache.poi.xssf.usermodel.XSSFColor(Color.BLACK));
    cs.setFillForegroundColor(new org.apache.poi.xssf.usermodel.XSSFColor(Color.YELLOW));
    cs.setAlignment(HorizontalAlignment.CENTER);
    cs.setVerticalAlignment(VerticalAlignment.CENTER);
    cs.setBorderBottom(BorderStyle.DASHED);
    cs.setBorderTop(BorderStyle.DASHED);
    cs.setBorderLeft(BorderStyle.DASHED);
    cs.setBorderRight(BorderStyle.DASHED);
}

From source file:cn.afterturn.easypoi.excel.html.css.impl.BorderCssConverImpl.java

License:Apache License

@Override
public void convertToExcel(Cell cell, CellStyle cellStyle, CellStyleEntity style) {
    if (style == null || style.getBorder() == null) {
        return;/*from  w  w  w  . j av a2s  .co  m*/
    }
    CellStyleBorderEntity border = style.getBorder();
    for (String pos : new String[] { TOP, RIGHT, BOTTOM, LEFT }) {
        String posName = StringUtils.capitalize(pos.toLowerCase());
        // color
        String colorAttr = null;
        try {
            colorAttr = (String) MethodUtils.invokeMethod(border, "getBorder" + posName + "Color");
        } catch (Exception e) {
            log.error("Set Border Style Error Caused.", e);
        }
        if (StringUtils.isNotEmpty(colorAttr)) {
            if (cell instanceof HSSFCell) {
                HSSFColor poiColor = PoiCssUtils.parseColor((HSSFWorkbook) cell.getSheet().getWorkbook(),
                        colorAttr);
                if (poiColor != null) {
                    try {
                        MethodUtils.invokeMethod(cellStyle, "set" + posName + "BorderColor",
                                poiColor.getIndex());
                    } catch (Exception e) {
                        log.error("Set Border Color Error Caused.", e);
                    }
                }
            }
            if (cell instanceof XSSFCell) {
                XSSFColor poiColor = PoiCssUtils.parseColor(colorAttr);
                if (poiColor != null) {
                    try {
                        MethodUtils.invokeMethod(cellStyle, "set" + posName + "BorderColor", poiColor);
                    } catch (Exception e) {
                        log.error("Set Border Color Error Caused.", e);
                    }
                }
            }
        }
        // width
        int width = 0;
        try {
            String widthStr = (String) MethodUtils.invokeMethod(border, "getBorder" + posName + "Width");
            if (PoiCssUtils.isNum(widthStr)) {
                width = Integer.parseInt(widthStr);
            }
        } catch (Exception e) {
            log.error("Set Border Style Error Caused.", e);
        }
        String styleValue = null;
        try {
            styleValue = (String) MethodUtils.invokeMethod(border, "getBorder" + posName + "Style");
        } catch (Exception e) {
            log.error("Set Border Style Error Caused.", e);
        }
        BorderStyle shortValue = BorderStyle.NONE;
        // empty or solid
        if (StringUtils.isBlank(styleValue) || "solid".equals(styleValue)) {
            if (width > 2) {
                shortValue = BorderStyle.THICK;
            } else if (width > 1) {
                shortValue = BorderStyle.MEDIUM;
            } else {
                shortValue = BorderStyle.THIN;
            }
        } else if (ArrayUtils.contains(new String[] { NONE, HIDDEN }, styleValue)) {
            shortValue = BorderStyle.NONE;
        } else if (DOUBLE.equals(styleValue)) {
            shortValue = BorderStyle.DOUBLE;
        } else if (DOTTED.equals(styleValue)) {
            shortValue = BorderStyle.DOTTED;
        } else if (DASHED.equals(styleValue)) {
            if (width > 1) {
                shortValue = BorderStyle.MEDIUM_DASHED;
            } else {
                shortValue = BorderStyle.DASHED;
            }
        }
        // border style
        if (shortValue != BorderStyle.NONE) {
            try {
                MethodUtils.invokeMethod(cellStyle, "setBorder" + posName, shortValue);
            } catch (Exception e) {
                log.error("Set Border Style Error Caused.", e);
            }
        }
    }
}

From source file:com.github.ukase.toolkit.xlsx.XlsxUtil.java

License:Open Source License

private static BorderStyle prepareBorder(float width, IdentValue ident) {
    if (width >= 40.0F) {
        if (XlsxUtil.isDashed(ident)) {
            return BorderStyle.MEDIUM_DASHED;
        } else if (XlsxUtil.isDotted(ident)) {
            return BorderStyle.MEDIUM_DASH_DOT;
        }//www.ja  v a  2 s.co m
        return BorderStyle.THICK;
    } else if (width >= 20.0F) {
        if (XlsxUtil.isDashed(ident)) {
            return BorderStyle.DASHED;
        } else if (XlsxUtil.isDotted(ident)) {
            return BorderStyle.DOTTED;
        }
        return BorderStyle.MEDIUM;
    } else if (width >= 0.1F) {
        if (XlsxUtil.isDotted(ident)) {
            return BorderStyle.HAIR;
        }
        return BorderStyle.THIN;
    } else {
        return BorderStyle.NONE;
    }
}

From source file:com.hauldata.dbpa.file.book.XlsxTargetSheet.java

License:Apache License

private static BorderStyle resolveBorderStyle(BorderStyles border) {

    BorderWidth borderWidth = (border.width != null) ? border.width : BorderWidth.MEDIUM;
    BorderEdge borderStyle = (border.style != null) ? border.style : BorderEdge.NONE;

    if (borderWidth == BorderWidth.ZERO) {
        return BorderStyle.NONE;
    }/*from   w w w. j  a  v a2  s. c  o m*/

    switch (borderStyle) {
    case NONE:
    case HIDDEN:
        return BorderStyle.NONE;
    default:
    case SOLID:
        switch (borderWidth) {
        case THIN:
            return BorderStyle.THIN;
        default:
        case MEDIUM:
            return BorderStyle.MEDIUM;
        case THICK:
            return BorderStyle.THICK;
        }
    case DOUBLE:
        return BorderStyle.DOUBLE;
    case DASHED:
        switch (borderWidth) {
        case THIN:
            return BorderStyle.DASHED;
        default:
        case MEDIUM:
        case THICK:
            return BorderStyle.MEDIUM_DASHED;
        }
    case DOTTED:
        return BorderStyle.DOTTED;
    }
}

From source file:com.l3.info.magenda.emplois_du_temps.Workbook.java

public void initialiserPalettedestyle(XSSFWorkbook workbook) {
    liste_des_styles = new HashMap<>();
    XSSFCellStyle style = (XSSFCellStyle) workbook.createCellStyle();

    style.setBorderBottom(BorderStyle.MEDIUM);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());

    style.setBorderLeft(BorderStyle.MEDIUM);
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());

    style.setBorderRight(BorderStyle.MEDIUM);
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());

    style.setBorderTop(BorderStyle.MEDIUM);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());

    liste_des_styles.put("nom_du_jour", style);
    style = (XSSFCellStyle) workbook.createCellStyle();

    style.setBorderBottom(BorderStyle.MEDIUM);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());

    style.setBorderLeft(BorderStyle.MEDIUM);
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());

    style.setBorderRight(BorderStyle.DASHED);
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());

    style.setBorderTop(BorderStyle.MEDIUM);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());

    liste_des_styles.put("case_gauche_jour", style);
    style = (XSSFCellStyle) workbook.createCellStyle();

    style.setBorderBottom(BorderStyle.MEDIUM);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());

    style.setBorderLeft(BorderStyle.DASHED);
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());

    style.setBorderRight(BorderStyle.MEDIUM);
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());

    style.setBorderTop(BorderStyle.MEDIUM);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());

    liste_des_styles.put("case_droite_jour", style);
}

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

License:Open Source License

@Test
public void testXlsx_BackgroundStyle() {
    when(workbook.createCellStyle()).thenReturn(xlsxStyle);
    ExcelCellStyleBuilder builder = new ExcelCellStyleBuilder(workbook);

    CellBackground bg = getBackground();
    HSSFCellStyleProducer.HSSFCellStyleKey styleKey = getXlsxKey();

    builder.withBackgroundStyle(bg, styleKey);

    verify(xlsxStyle, times(1)).setBorderBottom(eq(BorderStyle.DASH_DOT));
    verify(xlsxStyle, times(1)).setBorderColor(eq(XSSFCellBorder.BorderSide.BOTTOM), notNull(XSSFColor.class));
    verify(xlsxStyle, times(1)).setBorderTop(eq(BorderStyle.DOTTED));
    verify(xlsxStyle, times(1)).setBorderColor(eq(XSSFCellBorder.BorderSide.TOP), notNull(XSSFColor.class));
    verify(xlsxStyle, times(1)).setBorderLeft(eq(BorderStyle.DASH_DOT_DOT));
    verify(xlsxStyle, times(1)).setBorderColor(eq(XSSFCellBorder.BorderSide.LEFT), notNull(XSSFColor.class));
    verify(xlsxStyle, times(1)).setBorderRight(eq(BorderStyle.DASHED));
    verify(xlsxStyle, times(1)).setBorderColor(eq(XSSFCellBorder.BorderSide.RIGHT), notNull(XSSFColor.class));
    verify(xlsxStyle, times(1)).setFillForegroundColor(notNull(XSSFColor.class));
    verify(xlsxStyle, times(1)).setFillPattern(eq(FillPatternType.SOLID_FOREGROUND));
}

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

License:Open Source License

private HSSFCellStyleProducer.HSSFCellStyleKey getXlsxKey() {
    when(styleKey.getBorderStrokeBottom()).thenReturn(BorderStyle.DASH_DOT);
    when(styleKey.getExtendedColorBottom()).thenReturn(Color.BLACK);
    when(styleKey.getBorderStrokeTop()).thenReturn(BorderStyle.DOTTED);
    when(styleKey.getExtendedColorTop()).thenReturn(Color.BLACK);
    when(styleKey.getBorderStrokeLeft()).thenReturn(BorderStyle.DASH_DOT_DOT);
    when(styleKey.getExtendedColorLeft()).thenReturn(Color.BLACK);
    when(styleKey.getBorderStrokeLeft()).thenReturn(BorderStyle.DASH_DOT_DOT);
    when(styleKey.getBorderStrokeRight()).thenReturn(BorderStyle.DASHED);
    when(styleKey.getExtendedColorRight()).thenReturn(Color.BLACK);
    when(styleKey.getExtendedColor()).thenReturn(Color.BLACK);

    return styleKey;
}