List of usage examples for org.apache.poi.ss.usermodel BorderStyle NONE
BorderStyle NONE
To view the source code for org.apache.poi.ss.usermodel BorderStyle NONE.
Click Source Link
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 .ja v a 2s . c om } 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; }/* w w w . j av a 2 s.c om*/ 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; }/* www .j a va2 s . com*/ 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:guru.qas.martini.report.DefaultState.java
License:Apache License
protected void colorRow(short color, Row row) { short firstCellNum = row.getFirstCellNum(); short lastCellNum = row.getLastCellNum(); for (int i = firstCellNum; i <= lastCellNum; i++) { Cell cell = row.getCell(i);/*from ww w . ja va 2s. c om*/ if (null != cell) { CellStyle cellStyle = cell.getCellStyle(); Workbook workbook = cell.getSheet().getWorkbook(); CellStyle clone = workbook.createCellStyle(); clone.cloneStyleFrom(cellStyle); clone.setFillForegroundColor(color); clone.setFillPattern(FillPatternType.SOLID_FOREGROUND); BorderStyle borderStyle = cellStyle.getBorderLeftEnum(); clone.setBorderLeft(BorderStyle.NONE == borderStyle ? BorderStyle.THIN : borderStyle); short borderColor = cellStyle.getLeftBorderColor(); clone.setLeftBorderColor(0 == borderColor ? IndexedColors.BLACK.getIndex() : borderColor); borderStyle = cellStyle.getBorderRightEnum(); clone.setBorderRight(BorderStyle.NONE == borderStyle ? BorderStyle.THIN : borderStyle); borderColor = cellStyle.getRightBorderColor(); clone.setRightBorderColor(0 == borderColor ? IndexedColors.BLACK.getIndex() : borderColor); borderStyle = cellStyle.getBorderTopEnum(); clone.setBorderTop(BorderStyle.NONE == borderStyle ? BorderStyle.THIN : borderStyle); borderColor = cellStyle.getTopBorderColor(); clone.setTopBorderColor(0 == borderColor ? IndexedColors.BLACK.getIndex() : borderColor); borderStyle = cellStyle.getBorderBottomEnum(); clone.setBorderBottom(BorderStyle.NONE == borderStyle ? BorderStyle.THIN : borderStyle); borderColor = cellStyle.getBottomBorderColor(); clone.setBottomBorderColor(borderColor); cell.setCellStyle(clone); } } }
From source file:org.jkiss.dbeaver.data.office.export.DataExporterXLSX.java
License:Apache License
@Override public void init(IStreamDataExporterSite site) throws DBException { Object nullStringProp = site.getProperties().get(PROP_NULL_STRING); nullString = nullStringProp == null ? null : nullStringProp.toString(); try {//from w w w . j ava 2 s . c o m printHeader = (Boolean) site.getProperties().get(PROP_HEADER); } catch (Exception e) { printHeader = false; } try { rowNumber = (Boolean) site.getProperties().get(PROP_ROWNUMBER); } catch (Exception e) { rowNumber = false; } try { boolTrue = (String) site.getProperties().get(PROP_TRUESTRING); } catch (Exception e) { boolTrue = "true"; } try { boolFalse = (String) site.getProperties().get(PROP_FALSESTRING); } catch (Exception e) { boolFalse = "false"; } if (!"true".equals(boolTrue) || !"false".equals(boolFalse)) { booleRedefined = true; } try { exportSql = (Boolean) site.getProperties().get(PROP_EXPORT_SQL); } catch (Exception e) { exportSql = false; } try { splitSqlText = (Boolean) site.getProperties().get(PROP_SPLIT_SQLTEXT); } catch (Exception e) { splitSqlText = false; } try { splitByRowCount = (Integer) site.getProperties().get(PROP_SPLIT_BYROWCOUNT); } catch (Exception e) { splitByRowCount = EXCEL2007MAXROWS; } try { splitByCol = (Integer) site.getProperties().get(PROP_SPLIT_BYCOL); } catch (Exception e) { splitByCol = -1; } wb = new SXSSFWorkbook(ROW_WINDOW); worksheets = new HashMap<>(1); styleHeader = (XSSFCellStyle) wb.createCellStyle(); BorderStyle border; try { border = BorderStyle.valueOf((String) site.getProperties().get(PROP_BORDER)); } catch (Exception e) { border = BorderStyle.NONE; } FontStyleProp fontStyle; try { fontStyle = FontStyleProp.valueOf((String) site.getProperties().get(PROP_HEADER_FONT)); } catch (Exception e) { fontStyle = FontStyleProp.NONE; } styleHeader.setBorderTop(border); styleHeader.setBorderBottom(border); styleHeader.setBorderLeft(border); styleHeader.setBorderRight(border); XSSFFont fontBold = (XSSFFont) wb.createFont(); switch (fontStyle) { case BOLD: fontBold.setBold(true); break; case ITALIC: fontBold.setItalic(true); break; case STRIKEOUT: fontBold.setStrikeout(true); break; case UNDERLINE: fontBold.setUnderline((byte) 3); break; default: break; } styleHeader.setFont(fontBold); style = (XSSFCellStyle) wb.createCellStyle(); style.setBorderTop(border); style.setBorderBottom(border); style.setBorderLeft(border); style.setBorderRight(border); this.rowCount = 0; super.init(site); }
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. *//*w w w . j a v a 2 s.c o m*/ 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.sysmodb.xml.XMLStyleGenerator.java
License:BSD License
public static boolean isStyleEmpty(CellStyle style, XMLStyleHelper helper) { if (style.getBorderTopEnum() != BorderStyle.NONE) return false; if (style.getBorderBottomEnum() != BorderStyle.NONE) return false; if (style.getBorderLeftEnum() != BorderStyle.NONE) return false; if (style.getBorderRightEnum() != BorderStyle.NONE) return false; // Background/fill colour if ((helper.getBGColour(style)) != null) return false; return helper.areFontsEmpty(style); }
From source file:uk.co.spudsoft.birt.emitters.excel.StyleManagerXUtils.java
License:Open Source License
/** * Converts a BIRT border style into a POI BorderStyle. * @param birtBorder// www. j ava 2s . c o m * The BIRT border style. * @param width * The width of the border as understood by BIRT. * @return * A POI BorderStyle object. */ private BorderStyle poiBorderStyleFromBirt(String birtBorder, String width) { if ("none".equals(birtBorder)) { return BorderStyle.NONE; } double pxWidth = 3.0; if (CSSConstants.CSS_THIN_VALUE.equals(width)) { pxWidth = 1.0; } else if (CSSConstants.CSS_MEDIUM_VALUE.equals(width)) { pxWidth = 3.0; } else if (CSSConstants.CSS_THICK_VALUE.equals(width)) { pxWidth = 4.0; } else { DimensionType dim = DimensionType.parserUnit(width); if (dim != null) { if ("px".equals(dim.getUnits())) { pxWidth = dim.getMeasure(); } } } if ("solid".equals(birtBorder)) { if (pxWidth < 2.9) { return BorderStyle.THIN; } else if (pxWidth < 3.1) { return BorderStyle.MEDIUM; } else { return BorderStyle.THICK; } } else if ("dashed".equals(birtBorder)) { if (pxWidth < 2.9) { return BorderStyle.DASHED; } else { return BorderStyle.MEDIUM_DASHED; } } else if ("dotted".equals(birtBorder)) { return BorderStyle.DOTTED; } else if ("double".equals(birtBorder)) { return BorderStyle.DOUBLE; } log.debug("Border style \"", birtBorder, "\" is not recognised."); return BorderStyle.NONE; }
From source file:uk.co.spudsoft.birt.emitters.excel.StyleManagerXUtils.java
License:Open Source License
@Override public void applyBorderStyle(Workbook workbook, CellStyle style, BorderSide side, CSSValue colour, CSSValue borderStyle, CSSValue width) { if ((colour != null) || (borderStyle != null) || (width != null)) { String colourString = colour == null ? "rgb(0,0,0)" : colour.getCssText(); String borderStyleString = borderStyle == null ? "solid" : borderStyle.getCssText(); String widthString = width == null ? "medium" : width.getCssText(); if (style instanceof XSSFCellStyle) { XSSFCellStyle xStyle = (XSSFCellStyle) style; BorderStyle xBorderStyle = poiBorderStyleFromBirt(borderStyleString, widthString); XSSFColor xBorderColour = getXColour(colourString); if (xBorderStyle != BorderStyle.NONE) { switch (side) { case TOP: xStyle.setBorderTop(xBorderStyle); xStyle.setTopBorderColor(xBorderColour); // log.debug( "Top border: " + xStyle.getBorderTop() + " / " + xStyle.getTopBorderXSSFColor().getARGBHex() ); break; case LEFT: xStyle.setBorderLeft(xBorderStyle); xStyle.setLeftBorderColor(xBorderColour); // log.debug( "Left border: " + xStyle.getBorderLeft() + " / " + xStyle.getLeftBorderXSSFColor().getARGBHex() ); break; case RIGHT: xStyle.setBorderRight(xBorderStyle); xStyle.setRightBorderColor(xBorderColour); // log.debug( "Right border: " + xStyle.getBorderRight() + " / " + xStyle.getRightBorderXSSFColor().getARGBHex() ); break; case BOTTOM: xStyle.setBorderBottom(xBorderStyle); xStyle.setBottomBorderColor(xBorderColour); // log.debug( "Bottom border: " + xStyle.getBorderBottom() + " / " + xStyle.getBottomBorderXSSFColor().getARGBHex() ); break; }/*from w w w . j a v a 2 s.c om*/ } } } }