use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTUnderlineProperty in project poi by apache.
the class XSSFFont method setUnderline.
/**
* set an enumeration representing the style of underlining that is used.
* The none style is equivalent to not using underlining at all.
* The possible values for this attribute are defined by the FontUnderline
*
* @param underline - FontUnderline enum value
*/
public void setUnderline(FontUnderline underline) {
if (underline == FontUnderline.NONE && _ctFont.sizeOfUArray() > 0) {
_ctFont.setUArray(null);
} else {
CTUnderlineProperty ctUnderline = _ctFont.sizeOfUArray() == 0 ? _ctFont.addNewU() : _ctFont.getUArray(0);
STUnderlineValues.Enum val = STUnderlineValues.Enum.forInt(underline.getValue());
ctUnderline.setVal(val);
}
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTUnderlineProperty in project poi by apache.
the class TestXSSFFont method testUnderline.
@Test
public void testUnderline() {
CTFont ctFont = CTFont.Factory.newInstance();
CTUnderlineProperty underlinePropr = ctFont.addNewU();
underlinePropr.setVal(STUnderlineValues.SINGLE);
ctFont.setUArray(0, underlinePropr);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(Font.U_SINGLE, xssfFont.getUnderline());
xssfFont.setUnderline(Font.U_DOUBLE);
assertEquals(ctFont.sizeOfUArray(), 1);
assertEquals(STUnderlineValues.DOUBLE, ctFont.getUArray(0).getVal());
xssfFont.setUnderline(FontUnderline.DOUBLE_ACCOUNTING);
assertEquals(ctFont.sizeOfUArray(), 1);
assertEquals(STUnderlineValues.DOUBLE_ACCOUNTING, ctFont.getUArray(0).getVal());
}
Aggregations