use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder in project poi by apache.
the class XSSFCellStyle method setBorderLeft.
/**
* Set the type of border to use for the left border of the cell
*
* @param border the type of border to use
* @since POI 3.15
*/
@Override
public void setBorderLeft(BorderStyle border) {
CTBorder ct = getCTBorder();
CTBorderPr pr = ct.isSetLeft() ? ct.getLeft() : ct.addNewLeft();
if (border == BorderStyle.NONE)
ct.unsetLeft();
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.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder in project poi by apache.
the class XSSFCellStyle method getBorderTopEnum.
/**
* Get the type of border to use for the top border of the cell
* Will be removed when {@link #getBorderTop()} returns a BorderStyle enum
*
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE}
* @since POI 3.15
*/
@Override
public BorderStyle getBorderTopEnum() {
if (!_cellXf.getApplyBorder())
return BorderStyle.NONE;
int idx = (int) _cellXf.getBorderId();
CTBorder ct = _stylesSource.getBorderAt(idx).getCTBorder();
STBorderStyle.Enum ptrn = ct.isSetTop() ? ct.getTop().getStyle() : null;
if (ptrn == null) {
return BorderStyle.NONE;
}
return BorderStyle.valueOf((short) (ptrn.intValue() - 1));
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder in project poi by apache.
the class TestXSSFBorder method testGetBorderStyle.
public void testGetBorderStyle() {
CTStylesheet stylesheet = CTStylesheet.Factory.newInstance();
CTBorder border = stylesheet.addNewBorders().addNewBorder();
CTBorderPr top = border.addNewTop();
CTBorderPr right = border.addNewRight();
CTBorderPr bottom = border.addNewBottom();
top.setStyle(STBorderStyle.DASH_DOT);
right.setStyle(STBorderStyle.NONE);
bottom.setStyle(STBorderStyle.THIN);
XSSFCellBorder cellBorderStyle = new XSSFCellBorder(border);
assertEquals("DASH_DOT", cellBorderStyle.getBorderStyle(BorderSide.TOP).toString());
assertEquals("NONE", cellBorderStyle.getBorderStyle(BorderSide.RIGHT).toString());
assertEquals(BorderStyle.NONE.ordinal(), cellBorderStyle.getBorderStyle(BorderSide.RIGHT).ordinal());
assertEquals("THIN", cellBorderStyle.getBorderStyle(BorderSide.BOTTOM).toString());
assertEquals(BorderStyle.THIN.ordinal(), cellBorderStyle.getBorderStyle(BorderSide.BOTTOM).ordinal());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder in project poi by apache.
the class TestXWPFParagraph method testSetGetBorderTop.
@Test
public void testSetGetBorderTop() throws IOException {
//new clean instance of paragraph
XWPFDocument doc = new XWPFDocument();
XWPFParagraph p = doc.createParagraph();
assertEquals(STBorder.NONE.intValue(), p.getBorderTop().getValue());
CTP ctp = p.getCTP();
CTPPr ppr = ctp.getPPr() == null ? ctp.addNewPPr() : ctp.getPPr();
//bordi
CTPBdr bdr = ppr.addNewPBdr();
CTBorder borderTop = bdr.addNewTop();
borderTop.setVal(STBorder.DOUBLE);
bdr.setTop(borderTop);
assertEquals(Borders.DOUBLE, p.getBorderTop());
p.setBorderTop(Borders.SINGLE);
assertEquals(STBorder.SINGLE, borderTop.getVal());
doc.close();
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder in project poi by apache.
the class XWPFTable method setInsideHBorder.
public void setInsideHBorder(XWPFBorderType type, int size, int space, String rgbColor) {
CTTblPr tblPr = getTrPr();
CTTblBorders ctb = tblPr.isSetTblBorders() ? tblPr.getTblBorders() : tblPr.addNewTblBorders();
CTBorder b = ctb.isSetInsideH() ? ctb.getInsideH() : ctb.addNewInsideH();
b.setVal(xwpfBorderTypeMap.get(type));
b.setSz(BigInteger.valueOf(size));
b.setSpace(BigInteger.valueOf(space));
b.setColor(rgbColor);
}
Aggregations