Search in sources :

Example 11 with XSSFCellBorder

use of org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder in project poi by apache.

the class XSSFCellStyle method setBorderTop.

/**
     * Set the type of border to use for the top border of the cell
     *
     * @param border the type of border to use
     * @since POI 3.15
     */
@Override
public void setBorderTop(BorderStyle border) {
    CTBorder ct = getCTBorder();
    CTBorderPr pr = ct.isSetTop() ? ct.getTop() : ct.addNewTop();
    if (border == BorderStyle.NONE)
        ct.unsetTop();
    else
        pr.setStyle(STBorderStyle.Enum.forInt(border.getCode() + 1));
    int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme, _stylesSource.getIndexedColors()));
    _cellXf.setBorderId(idx);
    _cellXf.setApplyBorder(true);
}
Also used : CTBorder(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder) CTBorderPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr) XSSFCellBorder(org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder)

Example 12 with XSSFCellBorder

use of org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder in project poi by apache.

the class XSSFCellStyle method setTopBorderColor.

/**
     * Set the color to use for the top border as a {@link XSSFColor} value
     *
     * @param color the color to use
     */
public void setTopBorderColor(XSSFColor color) {
    CTBorder ct = getCTBorder();
    if (color == null && !ct.isSetTop())
        return;
    CTBorderPr pr = ct.isSetTop() ? ct.getTop() : ct.addNewTop();
    if (color != null)
        pr.setColor(color.getCTColor());
    else
        pr.unsetColor();
    int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme, _stylesSource.getIndexedColors()));
    _cellXf.setBorderId(idx);
    _cellXf.setApplyBorder(true);
}
Also used : CTBorder(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder) CTBorderPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr) XSSFCellBorder(org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder)

Example 13 with XSSFCellBorder

use of org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder in project poi by apache.

the class XSSFCellStyle method setLeftBorderColor.

/**
     * Set the color to use for the left border as a {@link XSSFColor} value
     *
     * @param color the color to use
     */
public void setLeftBorderColor(XSSFColor color) {
    CTBorder ct = getCTBorder();
    if (color == null && !ct.isSetLeft())
        return;
    CTBorderPr pr = ct.isSetLeft() ? ct.getLeft() : ct.addNewLeft();
    if (color != null)
        pr.setColor(color.getCTColor());
    else
        pr.unsetColor();
    int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme, _stylesSource.getIndexedColors()));
    _cellXf.setBorderId(idx);
    _cellXf.setApplyBorder(true);
}
Also used : CTBorder(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder) CTBorderPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr) XSSFCellBorder(org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder)

Example 14 with XSSFCellBorder

use of org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder in project poi by apache.

the class XSSFCellStyle method getRightBorderXSSFColor.

/**
     * Get the color to use for the right border
     *
     * @return the used color or <code>null</code> if not set
     */
public XSSFColor getRightBorderXSSFColor() {
    if (!_cellXf.getApplyBorder())
        return null;
    int idx = (int) _cellXf.getBorderId();
    XSSFCellBorder border = _stylesSource.getBorderAt(idx);
    return border.getBorderColor(BorderSide.RIGHT);
}
Also used : XSSFCellBorder(org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder)

Example 15 with XSSFCellBorder

use of org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder in project poi by apache.

the class XSSFCellStyle method setBorderBottom.

/**
     * Set the type of border to use for the bottom border of the cell
     *
     * @param border - type of border to use
     * @see org.apache.poi.ss.usermodel.BorderStyle
     * @since POI 3.15
     */
@Override
public void setBorderBottom(BorderStyle border) {
    CTBorder ct = getCTBorder();
    CTBorderPr pr = ct.isSetBottom() ? ct.getBottom() : ct.addNewBottom();
    if (border == BorderStyle.NONE)
        ct.unsetBottom();
    else
        pr.setStyle(STBorderStyle.Enum.forInt(border.getCode() + 1));
    int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme, _stylesSource.getIndexedColors()));
    _cellXf.setBorderId(idx);
    _cellXf.setApplyBorder(true);
}
Also used : CTBorder(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder) CTBorderPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr) XSSFCellBorder(org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder)

Aggregations

XSSFCellBorder (org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder)18 CTBorder (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder)9 CTBorderPr (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr)8 XSSFCellFill (org.apache.poi.xssf.usermodel.extensions.XSSFCellFill)4 XSSFFont (org.apache.poi.xssf.usermodel.XSSFFont)3 IOException (java.io.IOException)1 StylesTable (org.apache.poi.xssf.model.StylesTable)1 CustomIndexedColorMap (org.apache.poi.xssf.usermodel.CustomIndexedColorMap)1 DefaultIndexedColorMap (org.apache.poi.xssf.usermodel.DefaultIndexedColorMap)1 IndexedColorMap (org.apache.poi.xssf.usermodel.IndexedColorMap)1 XSSFTableStyle (org.apache.poi.xssf.usermodel.XSSFTableStyle)1 XmlException (org.apache.xmlbeans.XmlException)1 Before (org.junit.Before)1