use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill in project poi by apache.
the class XSSFCellStyle method setFillForegroundColor.
/**
* Set the foreground fill color represented as a {@link XSSFColor} value.
* <br/>
* <i>Note: Ensure Foreground color is set prior to background color.</i>
* @param color the color to use
* @see #setFillBackgroundColor(org.apache.poi.xssf.usermodel.XSSFColor) )
*/
public void setFillForegroundColor(XSSFColor color) {
CTFill ct = getCTFill();
CTPatternFill ptrn = ct.getPatternFill();
if (color == null) {
if (ptrn != null && ptrn.isSetFgColor())
ptrn.unsetFgColor();
} else {
if (ptrn == null)
ptrn = ct.addNewPatternFill();
ptrn.setFgColor(color.getCTColor());
}
addFill(ct);
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill in project poi by apache.
the class XSSFCellStyle method setFillPattern.
/**
* This element is used to specify cell fill information for pattern and solid color cell fills. For solid cell fills (no pattern),
* foreground color is used is used. For cell fills with patterns specified, then the cell fill color is specified by the background color element.
*
* @param pattern the fill pattern to use
* @see #setFillBackgroundColor(XSSFColor)
* @see #setFillForegroundColor(XSSFColor)
* @see org.apache.poi.ss.usermodel.FillPatternType
*/
@Override
public void setFillPattern(FillPatternType pattern) {
CTFill ct = getCTFill();
CTPatternFill ctptrn = ct.isSetPatternFill() ? ct.getPatternFill() : ct.addNewPatternFill();
if (pattern == FillPatternType.NO_FILL && ctptrn.isSetPatternType()) {
ctptrn.unsetPatternType();
} else {
ctptrn.setPatternType(STPatternType.Enum.forInt(pattern.getCode() + 1));
}
addFill(ct);
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill in project poi by apache.
the class TestXSSFCellFill method testGetNotModifies.
@Test
public void testGetNotModifies() {
CTFill ctFill = CTFill.Factory.newInstance();
XSSFCellFill cellFill = new XSSFCellFill(ctFill, null);
CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
ctPatternFill.setPatternType(STPatternType.DARK_DOWN);
assertEquals(8, cellFill.getPatternType().intValue());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill in project poi by apache.
the class TestXSSFCellFill method testGetSetPatternType.
@Test
public void testGetSetPatternType() {
CTFill ctFill = CTFill.Factory.newInstance();
XSSFCellFill cellFill = new XSSFCellFill(ctFill, null);
CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
ctPatternFill.setPatternType(STPatternType.SOLID);
assertEquals(FillPatternType.SOLID_FOREGROUND.ordinal(), cellFill.getPatternType().intValue() - 1);
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill in project poi by apache.
the class XSSFCellFill method setFillForegroundColor.
/**
* Set the foreground fill color as a indexed color value
*
* @param index - the color to use
*/
public void setFillForegroundColor(int index) {
CTPatternFill ptrn = ensureCTPatternFill();
CTColor ctColor = ptrn.isSetFgColor() ? ptrn.getFgColor() : ptrn.addNewFgColor();
ctColor.setIndexed(index);
}
Aggregations