use of org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder in project poi by apache.
the class XSSFCellStyle method getBottomBorderXSSFColor.
/**
* Get the color to use for the bottom border as a {@link XSSFColor}
*
* @return the used color or <code>null</code> if not set
*/
public XSSFColor getBottomBorderXSSFColor() {
if (!_cellXf.getApplyBorder())
return null;
int idx = (int) _cellXf.getBorderId();
XSSFCellBorder border = _stylesSource.getBorderAt(idx);
return border.getBorderColor(BorderSide.BOTTOM);
}
use of org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder in project poi by apache.
the class XSSFCellStyle method getCTBorder.
/**
* Get a <b>copy</b> of the currently used CTBorder, if none is used, return a new instance.
*/
private CTBorder getCTBorder() {
CTBorder ct;
if (_cellXf.getApplyBorder()) {
int idx = (int) _cellXf.getBorderId();
XSSFCellBorder cf = _stylesSource.getBorderAt(idx);
ct = (CTBorder) cf.getCTBorder().copy();
} else {
ct = CTBorder.Factory.newInstance();
}
return ct;
}
use of org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder in project poi by apache.
the class XSSFCellStyle method setBorderRight.
/**
* Set the type of border to use for the right border of the cell
*
* @param border the type of border to use
* @since POI 3.15
*/
@Override
public void setBorderRight(BorderStyle border) {
CTBorder ct = getCTBorder();
CTBorderPr pr = ct.isSetRight() ? ct.getRight() : ct.addNewRight();
if (border == BorderStyle.NONE)
ct.unsetRight();
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);
}
use of org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder in project poi by apache.
the class XSSFCellStyle method addBorder.
private void addBorder(CTBorder border) {
int idx = _stylesSource.putBorder(new XSSFCellBorder(border, _theme, _stylesSource.getIndexedColors()));
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
}
use of org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder in project poi by apache.
the class TestXSSFCellStyle method setUp.
@Before
public void setUp() {
stylesTable = new StylesTable();
ctStylesheet = stylesTable.getCTStylesheet();
ctBorderA = CTBorder.Factory.newInstance();
XSSFCellBorder borderA = new XSSFCellBorder(ctBorderA);
long borderId = stylesTable.putBorder(borderA);
assertEquals(1, borderId);
XSSFCellBorder borderB = new XSSFCellBorder();
assertEquals(1, stylesTable.putBorder(borderB));
ctFill = CTFill.Factory.newInstance();
XSSFCellFill fill = new XSSFCellFill(ctFill, null);
long fillId = stylesTable.putFill(fill);
assertEquals(2, fillId);
ctFont = CTFont.Factory.newInstance();
XSSFFont font = new XSSFFont(ctFont);
long fontId = stylesTable.putFont(font);
assertEquals(1, fontId);
cellStyleXf = ctStylesheet.addNewCellStyleXfs().addNewXf();
cellStyleXf.setBorderId(1);
cellStyleXf.setFillId(1);
cellStyleXf.setFontId(1);
cellXfs = ctStylesheet.addNewCellXfs();
cellXf = cellXfs.addNewXf();
cellXf.setXfId(1);
cellXf.setBorderId(1);
cellXf.setFillId(1);
cellXf.setFontId(1);
stylesTable.putCellStyleXf(cellStyleXf);
stylesTable.putCellXf(cellXf);
cellStyle = new XSSFCellStyle(1, 1, stylesTable, null);
assertNotNull(stylesTable.getFillAt(1).getCTFill().getPatternFill());
assertEquals(STPatternType.INT_DARK_GRAY, stylesTable.getFillAt(1).getCTFill().getPatternFill().getPatternType().intValue());
}
Aggregations