Java Code Examples for org.apache.poi.ss.usermodel.BorderStyle#NONE
The following examples show how to use
org.apache.poi.ss.usermodel.BorderStyle#NONE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JRXlsMetadataExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
public void setPen(JRPen pen) { if ( borderStyle[TOP] == BorderStyle.NONE && borderStyle[LEFT] == BorderStyle.NONE && borderStyle[BOTTOM] == BorderStyle.NONE && borderStyle[RIGHT] == BorderStyle.NONE ) { BorderStyle style = JRXlsMetadataExporter.getBorderStyle(pen); short colour = JRXlsMetadataExporter.this.getWorkbookColor(pen.getLineColor()).getIndex(); borderStyle[TOP] = style; borderStyle[BOTTOM] = style; borderStyle[LEFT] = style; borderStyle[RIGHT] = style; borderColour[TOP] = colour; borderColour[BOTTOM] = colour; borderColour[LEFT] = colour; borderColour[RIGHT] = colour; } hash = computeHash(); }
Example 2
Source File: JRXlsExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
public void setPen(JRPen pen) { if ( borderStyle[TOP] == BorderStyle.NONE && borderStyle[LEFT] == BorderStyle.NONE && borderStyle[BOTTOM] == BorderStyle.NONE && borderStyle[RIGHT] == BorderStyle.NONE ) { BorderStyle style = JRXlsExporter.getBorderStyle(pen); short colour = JRXlsExporter.this.getWorkbookColor(pen.getLineColor()).getIndex(); borderStyle[TOP] = style; borderStyle[BOTTOM] = style; borderStyle[LEFT] = style; borderStyle[RIGHT] = style; borderColour[TOP] = colour; borderColour[BOTTOM] = colour; borderColour[LEFT] = colour; borderColour[RIGHT] = colour; } hash = computeHash(); }
Example 3
Source File: PropertyTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Draws the top border for a range of cells * </p> * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. */ private void drawTopBorder(CellRangeAddress range, BorderStyle borderType) { int row = range.getFirstRow(); int firstCol = range.getFirstColumn(); int lastCol = range.getLastColumn(); for (int i = firstCol; i <= lastCol; i++) { addProperty(row, i, CellUtil.BORDER_TOP, borderType); if (borderType == BorderStyle.NONE && row > 0) { addProperty(row - 1, i, CellUtil.BORDER_BOTTOM, borderType); } } }
Example 4
Source File: HSSFCellStyleProducer.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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. */ 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; } }
Example 5
Source File: POIUtils.java From xlsmapper with Apache License 2.0 | 5 votes |
/** * 結合を考慮してセルの罫線(下部)を取得する。 * * @param cell セル * @return {@literal BorderStyle} * @throws IllegalArgumentException {@literal cell is null.} */ public static BorderStyle getBorderBottom(final Cell cell) { ArgUtils.notNull(cell, "cell"); final Sheet sheet = cell.getSheet(); CellRangeAddress mergedRegion = getMergedRegion(sheet, cell.getRowIndex(), cell.getColumnIndex()); final Cell target; if(mergedRegion == null) { // 結合されていない場合 target = cell; } else { if(mergedRegion.getLastRow() == cell.getRowIndex()) { // 引数のCellが下部のセルの場合 target = cell; } else { target = getCell(sheet, cell.getColumnIndex(), mergedRegion.getLastRow()); } } final CellStyle style = target.getCellStyle(); if(style == null) { return BorderStyle.NONE; } else { return style.getBorderBottomEnum(); } }
Example 6
Source File: POIUtils.java From xlsmapper with Apache License 2.0 | 5 votes |
/** * 結合を考慮してセルの罫線(上部)を取得する。 * * @param cell セル * @return {@literal BorderStyle} * @throws IllegalArgumentException {@literal cell is null.} */ public static BorderStyle getBorderTop(final Cell cell) { ArgUtils.notNull(cell, "cell"); final Sheet sheet = cell.getSheet(); CellRangeAddress mergedRegion = getMergedRegion(sheet, cell.getRowIndex(), cell.getColumnIndex()); final Cell target; if(mergedRegion == null) { // 結合されていない場合 target = cell; } else { if(mergedRegion.getFirstRow() == cell.getRowIndex()) { // 引数のCellが上部のセルの場合 target = cell; } else { target = getCell(sheet, cell.getColumnIndex(), mergedRegion.getFirstRow()); } } final CellStyle style = target.getCellStyle(); if(style == null) { return BorderStyle.NONE; } else { return style.getBorderTopEnum(); } }
Example 7
Source File: POIUtils.java From xlsmapper with Apache License 2.0 | 5 votes |
/** * 結合を考慮してセルの罫線(右部)を取得する。 * * @param cell セル * @return {@literal BorderStyle} * @throws IllegalArgumentException {@literal cell is null.} */ public static BorderStyle getBorderLeft(final Cell cell) { ArgUtils.notNull(cell, "cell"); final Sheet sheet = cell.getSheet(); CellRangeAddress mergedRegion = getMergedRegion(sheet, cell.getRowIndex(), cell.getColumnIndex()); final Cell target; if(mergedRegion == null) { // 結合されていない場合 target = cell; } else { if(mergedRegion.getFirstColumn() == cell.getColumnIndex()) { // 引数のCellが左部のセルの場合 target = cell; } else { target = getCell(sheet, mergedRegion.getFirstColumn(), cell.getRowIndex()); } } final CellStyle style = target.getCellStyle(); if(style == null) { return BorderStyle.NONE; } else { return style.getBorderLeftEnum(); } }
Example 8
Source File: JRXlsMetadataExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * */ protected static BorderStyle getBorderStyle(JRPen pen) { float lineWidth = pen.getLineWidth(); if (lineWidth > 0f) { switch (pen.getLineStyleValue()) { case DOUBLE : { return BorderStyle.DOUBLE; } case DOTTED : { return BorderStyle.DOTTED; } case DASHED : { if (lineWidth >= 1f) { return BorderStyle.MEDIUM_DASHED; } return BorderStyle.DASHED; } case SOLID : default : { if (lineWidth >= 2f) { return BorderStyle.THICK; } else if (lineWidth >= 1f) { return BorderStyle.MEDIUM; } else if (lineWidth >= 0.5f) { return BorderStyle.THIN; } return BorderStyle.HAIR; } } } return BorderStyle.NONE; }
Example 9
Source File: PropertyTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Sets the color of the right border for a range of cells. If the border is * not drawn, it defaults to BORDER_THIN * </p> * * @param range * - {@link CellRangeAddress} range of cells on which colors are * set. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. */ private void drawRightBorderColor(CellRangeAddress range, short color) { int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); int col = range.getLastColumn(); for (int i = firstRow; i <= lastRow; i++) { if (getBorderStyle(i, col, CellUtil.BORDER_RIGHT) == BorderStyle.NONE) { drawRightBorder(new CellRangeAddress(i, i, col, col), BorderStyle.THIN); } addProperty(i, col, CellUtil.RIGHT_BORDER_COLOR, color); } }
Example 10
Source File: PropertyTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Sets the color of the left border for a range of cells. * </p> * * @param range * - {@link CellRangeAddress} range of cells on which colors are * set. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. */ private void drawLeftBorderColor(CellRangeAddress range, short color) { int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); int col = range.getFirstColumn(); for (int i = firstRow; i <= lastRow; i++) { if (getBorderStyle(i, col, CellUtil.BORDER_LEFT) == BorderStyle.NONE) { drawLeftBorder(new CellRangeAddress(i, i, col, col), BorderStyle.THIN); } addProperty(i, col, CellUtil.LEFT_BORDER_COLOR, color); } }
Example 11
Source File: PropertyTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Sets the color of the bottom border for a range of cells. * </p> * * @param range * - {@link CellRangeAddress} range of cells on which colors are * set. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. */ private void drawBottomBorderColor(CellRangeAddress range, short color) { int row = range.getLastRow(); int firstCol = range.getFirstColumn(); int lastCol = range.getLastColumn(); for (int i = firstCol; i <= lastCol; i++) { if (getBorderStyle(row, i, CellUtil.BORDER_BOTTOM) == BorderStyle.NONE) { drawBottomBorder(new CellRangeAddress(row, row, i, i), BorderStyle.THIN); } addProperty(row, i, CellUtil.BOTTOM_BORDER_COLOR, color); } }
Example 12
Source File: PropertyTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Sets the color of the top border for a range of cells. * </p> * * @param range * - {@link CellRangeAddress} range of cells on which colors are * set. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. */ private void drawTopBorderColor(CellRangeAddress range, short color) { int row = range.getFirstRow(); int firstCol = range.getFirstColumn(); int lastCol = range.getLastColumn(); for (int i = firstCol; i <= lastCol; i++) { if (getBorderStyle(row, i, CellUtil.BORDER_TOP) == BorderStyle.NONE) { drawTopBorder(new CellRangeAddress(row, row, i, i), BorderStyle.THIN); } addProperty(row, i, CellUtil.TOP_BORDER_COLOR, color); } }
Example 13
Source File: PropertyTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Draws the right border for a range of cells * </p> * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. */ private void drawRightBorder(CellRangeAddress range, BorderStyle borderType) { int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); int col = range.getLastColumn(); for (int i = firstRow; i <= lastRow; i++) { addProperty(i, col, CellUtil.BORDER_RIGHT, borderType); if (borderType == BorderStyle.NONE && col < SpreadsheetVersion.EXCEL2007.getMaxColumns() - 1) { addProperty(i, col + 1, CellUtil.BORDER_LEFT, borderType); } } }
Example 14
Source File: PropertyTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Draws the left border for a range of cells * </p> * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. */ private void drawLeftBorder(CellRangeAddress range, BorderStyle borderType) { int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); int col = range.getFirstColumn(); for (int i = firstRow; i <= lastRow; i++) { addProperty(i, col, CellUtil.BORDER_LEFT, borderType); if (borderType == BorderStyle.NONE && col > 0) { addProperty(i, col - 1, CellUtil.BORDER_RIGHT, borderType); } } }
Example 15
Source File: PropertyTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Draws the bottom border for a range of cells * </p> * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. */ private void drawBottomBorder(CellRangeAddress range, BorderStyle borderType) { int row = range.getLastRow(); int firstCol = range.getFirstColumn(); int lastCol = range.getLastColumn(); for (int i = firstCol; i <= lastCol; i++) { addProperty(row, i, CellUtil.BORDER_BOTTOM, borderType); if (borderType == BorderStyle.NONE && row < SpreadsheetVersion.EXCEL2007.getMaxRows() - 1) { addProperty(row + 1, i, CellUtil.BORDER_TOP, borderType); } } }
Example 16
Source File: JRXlsExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ protected static BorderStyle getBorderStyle(JRPen pen) { float lineWidth = pen.getLineWidth(); if (lineWidth > 0f) { switch (pen.getLineStyleValue()) { case DOUBLE : { return BorderStyle.DOUBLE; } case DOTTED : { return BorderStyle.DOTTED; } case DASHED : { if (lineWidth >= 1f) { return BorderStyle.MEDIUM_DASHED; } return BorderStyle.DASHED; } case SOLID : default : { if (lineWidth >= 2f) { return BorderStyle.THICK; } else if (lineWidth >= 1f) { return BorderStyle.MEDIUM; } else if (lineWidth >= 0.5f) { return BorderStyle.THIN; } return BorderStyle.HAIR; } } } return BorderStyle.NONE; }
Example 17
Source File: StyleManagerXUtils.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Converts a BIRT border style into a POI BorderStyle. * @param birtBorder * 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; }
Example 18
Source File: PropertyTemplate.java From lams with GNU General Public License v2.0 | 3 votes |
/** * Draws a group of cell borders for a cell range. The borders are not * applied to the cells at this time, just the template is drawn. To apply * the drawn borders to a sheet, use {@link #applyBorders}. * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. * @param extent * - {@link BorderExtent} of the borders to be * applied. */ public void drawBorders(CellRangeAddress range, BorderStyle borderType, short color, BorderExtent extent) { drawBorders(range, borderType, extent); if (borderType != BorderStyle.NONE) { drawBorderColors(range, color, extent); } }
Example 19
Source File: HSSFBorderFormatting.java From lams with GNU General Public License v2.0 | 2 votes |
/** * HSSF doesn't support table borders, so always {@link BorderStyle#NONE} * @see org.apache.poi.ss.usermodel.BorderFormatting#getBorderVerticalEnum() */ public BorderStyle getBorderVerticalEnum() { return BorderStyle.NONE; }
Example 20
Source File: HSSFBorderFormatting.java From lams with GNU General Public License v2.0 | 2 votes |
/** * HSSF doesn't support table borders, so always {@link BorderStyle#NONE} * @see org.apache.poi.ss.usermodel.BorderFormatting#getBorderHorizontalEnum() */ public BorderStyle getBorderHorizontalEnum() { return BorderStyle.NONE; }