Search in sources :

Example 1 with CTUnderlineProperty

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);
    }
}
Also used : STUnderlineValues(org.openxmlformats.schemas.spreadsheetml.x2006.main.STUnderlineValues) CTUnderlineProperty(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTUnderlineProperty)

Example 2 with CTUnderlineProperty

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());
}
Also used : CTFont(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont) CTUnderlineProperty(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTUnderlineProperty) Test(org.junit.Test)

Aggregations

CTUnderlineProperty (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTUnderlineProperty)2 Test (org.junit.Test)1 CTFont (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont)1 STUnderlineValues (org.openxmlformats.schemas.spreadsheetml.x2006.main.STUnderlineValues)1