Example usage for org.apache.poi.xssf.usermodel XSSFCellStyle getTopBorderColor

List of usage examples for org.apache.poi.xssf.usermodel XSSFCellStyle getTopBorderColor

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFCellStyle getTopBorderColor.

Prototype

@Override
public short getTopBorderColor() 

Source Link

Document

Get the color to use for the top border

Usage

From source file:de.escnet.ExcelTable.java

License:Open Source License

private void styleBorders(Map<String, String> styles, int rowIndex, int colIndex, Span span) {
    XSSFCell cell = getCell(rowIndex, colIndex);
    XSSFCellStyle cellStyle = cell.getCellStyle();
    if (cellStyle != null) {
        int topThickness = 0;
        if (rowIndex > rowMin) {
            XSSFCell topCell = getCell(rowIndex - 1, colIndex);
            if (topCell != null) {
                XSSFCellStyle topCellStyle = topCell.getCellStyle();
                if (topCellStyle != null) {
                    topThickness = getThickness(topCellStyle.getBorderBottom());
                }//  w  w w  . j ava  2  s. c om
            }
        }

        styleBorder(styles, "top", cellStyle.getBorderTop(), topThickness, cellStyle.getTopBorderColor());

        int leftThickness = 0;
        if (colIndex > colMin) {
            XSSFCell leftCell = getCell(rowIndex, colIndex - 1);
            if (leftCell != null) {
                XSSFCellStyle leftCellStyle = leftCell.getCellStyle();
                if (leftCellStyle != null) {
                    leftThickness = getThickness(leftCellStyle.getBorderRight());
                }
            }
        }

        styleBorder(styles, "left", cellStyle.getBorderLeft(), leftThickness, cellStyle.getLeftBorderColor());
    }

    cell = getCell(rowIndex + span.rowspan - 1, colIndex);
    cellStyle = cell.getCellStyle();
    if (cellStyle != null) {
        styleBorder(styles, "bottom", cellStyle.getBorderBottom(), 0, cellStyle.getBottomBorderColor());
    }

    cell = getCell(rowIndex, colIndex + span.colspan - 1);
    cellStyle = cell.getCellStyle();
    if (cellStyle != null) {
        styleBorder(styles, "right", cellStyle.getBorderRight(), 0, cellStyle.getRightBorderColor());
    }
}