Example usage for org.apache.poi.ss.usermodel CellStyle getBorderBottom

List of usage examples for org.apache.poi.ss.usermodel CellStyle getBorderBottom

Introduction

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

Prototype

BorderStyle getBorderBottom();

Source Link

Document

get the type of border to use for the bottom border of the cell

Usage

From source file:ru.icc.cells.ssdc.DataLoader.java

License:Apache License

private void fillCellStyle(CStyle cellStyle, CellStyle excelCellStyle) {
    Font excelFont = workbook.getFontAt(excelCellStyle.getFontIndex());
    // TODO    CFont newFont(excelFont)
    //CFont font = new CFont();
    //cellStyle.setFont( font );
    CFont font = cellStyle.getFont();/* w  w  w. ja  v a2s.c o m*/

    fillFont(font, excelFont);

    cellStyle.setHidden(excelCellStyle.getHidden());
    cellStyle.setLocked(excelCellStyle.getLocked());
    cellStyle.setWrapped(excelCellStyle.getWrapText());

    cellStyle.setIndention(excelCellStyle.getIndention());
    cellStyle.setRotation(excelCellStyle.getRotation());

    cellStyle.setHorzAlignment(this.getHorzAlignment(excelCellStyle.getAlignment()));
    cellStyle.setVertAlignment(this.getVertAlignment(excelCellStyle.getVerticalAlignment()));

    CBorder leftBorder = cellStyle.getLeftBorder();
    CBorder rightBorder = cellStyle.getRightBorder();
    CBorder topBorder = cellStyle.getTopBorder();
    CBorder bottomBorder = cellStyle.getBottomBorder();

    BorderType lbType = this.convertBorderType(excelCellStyle.getBorderLeft());
    BorderType rbType = this.convertBorderType(excelCellStyle.getBorderRight());
    BorderType tbType = this.convertBorderType(excelCellStyle.getBorderTop());
    BorderType bbType = this.convertBorderType(excelCellStyle.getBorderBottom());

    leftBorder.setType(lbType);
    rightBorder.setType(rbType);
    topBorder.setType(tbType);
    bottomBorder.setType(bbType);

    //   "Fill Background Color" ???,    ??,
    //   ? ??? .  ?  .
    //      "Fill Foreground Color"
    XSSFColor bgColor = (XSSFColor) excelCellStyle.getFillBackgroundColorColor();

    // ? Index   64,  ? ,         ,
    // ?  ?   null ? 
    if (null != bgColor && 64 != bgColor.getIndexed()) {
        String bgColorHexRGB = bgColor.getARGBHex().substring(2);
        cellStyle.setBgColor(new CColor(bgColorHexRGB));
    }

    //   "Fill Background Color"      ??,
    //   ? ??? .      
    XSSFColor fgColor = (XSSFColor) excelCellStyle.getFillForegroundColorColor();

    if (null != fgColor && 64 != fgColor.getIndexed()) {
        String fgColorHexRGB = fgColor.getARGBHex().substring(2);
        cellStyle.setFgColor(new CColor(fgColorHexRGB));
    }

    // TODO   
}

From source file:ru.spb.nicetu.tableviewer.server.XlsToHtml.java

License:Apache License

private void borderStyles(CellStyle style, Formatter out, boolean isBuiltIn) {
    styleOut("border-left", style.getBorderLeft(), BORDER, out, isBuiltIn);
    styleOut("border-right", style.getBorderRight(), BORDER, out, isBuiltIn);
    styleOut("border-top", style.getBorderTop(), BORDER, out, isBuiltIn);
    styleOut("border-bottom", style.getBorderBottom(), BORDER, out, isBuiltIn);
}

From source file:uk.co.spudsoft.birt.emitters.excel.tests.Borders1ReportTest.java

License:Open Source License

private void assertBorder(Sheet sheet, int row, int col, short bottom, short left, short right, short top) {

    Cell cell = sheet.getRow(row).getCell(col);
    CellStyle style = cell.getCellStyle();

    assertSingleBorder(sheet, row, "bottom", bottom, style.getBorderBottom());
    assertSingleBorder(sheet, row, "left", left, style.getBorderLeft());
    assertSingleBorder(sheet, row, "right", right, style.getBorderRight());
    assertSingleBorder(sheet, row, "top", top, style.getBorderTop());
}

From source file:uk.co.spudsoft.birt.emitters.excel.tests.Borders2ReportTest.java

License:Open Source License

/**
 * Check that the borders for a given cell match the expected values.
 * This is complicated by the fact that POI will not always give a particular cell the borders that are seen in Excel
 * - neighbouring cells may override the values for the chosen cell.
 * I don't know how to tell which takes precedence, but the following works for the tests I've carried out.
 *//*from  w w w  .  j  a v  a2s . c  o m*/
public static void assertBorder(Sheet sheet, int row, int col, short bottom, short left, short right,
        short top) {

    Row curRow = sheet.getRow(row);
    Row prevRow = (row > 0) ? sheet.getRow(row - 1) : null;
    Row nextRow = sheet.getRow(row + 1);
    Cell cell = curRow.getCell(col);
    CellStyle style = cell.getCellStyle();

    Cell cellUp = (prevRow == null) ? null : prevRow.getCell(col);
    Cell cellDown = (nextRow == null) ? null : nextRow.getCell(col);
    Cell cellLeft = (col == 0) ? null : curRow.getCell(col - 1);
    Cell cellRight = curRow.getCell(col + 1);

    CellStyle styleUp = (cellUp == null) ? null : cellUp.getCellStyle();
    CellStyle styleDown = (cellDown == null) ? null : cellDown.getCellStyle();
    CellStyle styleLeft = (cellLeft == null) ? null : cellLeft.getCellStyle();
    CellStyle styleRight = (cellRight == null) ? null : cellRight.getCellStyle();

    System.out.println("style == " + style);
    System.out.println("style == " + style);

    if ((top != style.getBorderTop()) && ((styleUp == null) || (top != styleUp.getBorderBottom()))) {
        assertEquals(top, style.getBorderTop());
    }
    if ((bottom != style.getBorderBottom()) && ((styleDown == null) || (bottom != styleDown.getBorderTop()))) {
        assertEquals(bottom, style.getBorderBottom());
    }
    if ((left != style.getBorderLeft()) && ((styleLeft == null) || (left != styleLeft.getBorderRight()))) {
        assertEquals(left, style.getBorderLeft());
    }
    if ((right != style.getBorderRight()) && ((styleRight == null) || (right != styleRight.getBorderLeft()))) {
        assertEquals(right, style.getBorderRight());
    }
}