Search in sources :

Example 11 with CTFont

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.

the class TestXSSFFont method testTypeOffset.

@Test
public void testTypeOffset() {
    CTFont ctFont = CTFont.Factory.newInstance();
    CTVerticalAlignFontProperty valign = ctFont.addNewVertAlign();
    valign.setVal(STVerticalAlignRun.BASELINE);
    ctFont.setVertAlignArray(0, valign);
    XSSFFont font = new XSSFFont(ctFont);
    assertEquals(Font.SS_NONE, font.getTypeOffset());
    font.setTypeOffset(XSSFFont.SS_SUPER);
    assertEquals(STVerticalAlignRun.SUPERSCRIPT, ctFont.getVertAlignArray(0).getVal());
}
Also used : CTVerticalAlignFontProperty(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTVerticalAlignFontProperty) CTFont(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont) Test(org.junit.Test)

Example 12 with CTFont

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.

the class TestXSSFFont method testColor.

@Test
public void testColor() {
    CTFont ctFont = CTFont.Factory.newInstance();
    CTColor color = ctFont.addNewColor();
    color.setIndexed(XSSFFont.DEFAULT_FONT_COLOR);
    ctFont.setColorArray(0, color);
    XSSFFont xssfFont = new XSSFFont(ctFont);
    assertEquals(IndexedColors.BLACK.getIndex(), xssfFont.getColor());
    xssfFont.setColor(IndexedColors.RED.getIndex());
    assertEquals(IndexedColors.RED.getIndex(), ctFont.getColorArray(0).getIndexed());
}
Also used : CTFont(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont) CTColor(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor) Test(org.junit.Test)

Example 13 with CTFont

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.

the class TestXSSFFont method testRgbColor.

@Test
public void testRgbColor() {
    CTFont ctFont = CTFont.Factory.newInstance();
    CTColor color = ctFont.addNewColor();
    color.setRgb(Integer.toHexString(0xFFFFFF).getBytes(LocaleUtil.CHARSET_1252));
    ctFont.setColorArray(0, color);
    XSSFFont xssfFont = new XSSFFont(ctFont);
    assertEquals(ctFont.getColorArray(0).getRgb()[0], xssfFont.getXSSFColor().getRGB()[0]);
    assertEquals(ctFont.getColorArray(0).getRgb()[1], xssfFont.getXSSFColor().getRGB()[1]);
    assertEquals(ctFont.getColorArray(0).getRgb()[2], xssfFont.getXSSFColor().getRGB()[2]);
    assertEquals(ctFont.getColorArray(0).getRgb()[3], xssfFont.getXSSFColor().getRGB()[3]);
    xssfFont.setColor((short) 23);
    byte[] bytes = Integer.toHexString(0xF1F1F1).getBytes(LocaleUtil.CHARSET_1252);
    color.setRgb(bytes);
    XSSFColor newColor = new XSSFColor(color, null);
    xssfFont.setColor(newColor);
    assertEquals(ctFont.getColorArray(0).getRgb()[2], newColor.getRGB()[2]);
    assertArrayEquals(bytes, xssfFont.getXSSFColor().getRGB());
    assertEquals(0, xssfFont.getColor());
}
Also used : CTFont(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont) CTColor(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor) Test(org.junit.Test)

Example 14 with CTFont

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.

the class TestXSSFFont method testFontHeightInPoint.

@Test
public void testFontHeightInPoint() {
    CTFont ctFont = CTFont.Factory.newInstance();
    CTFontSize size = ctFont.addNewSz();
    size.setVal(14);
    ctFont.setSzArray(0, size);
    XSSFFont xssfFont = new XSSFFont(ctFont);
    assertEquals(14, xssfFont.getFontHeightInPoints());
    xssfFont.setFontHeightInPoints((short) 20);
    assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
}
Also used : CTFontSize(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontSize) CTFont(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont) Test(org.junit.Test)

Example 15 with CTFont

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.

the class TestXSSFFont method testStrikeout.

@Test
public void testStrikeout() {
    CTFont ctFont = CTFont.Factory.newInstance();
    CTBooleanProperty bool = ctFont.addNewStrike();
    bool.setVal(false);
    ctFont.setStrikeArray(0, bool);
    XSSFFont xssfFont = new XSSFFont(ctFont);
    assertEquals(false, xssfFont.getStrikeout());
    xssfFont.setStrikeout(true);
    assertEquals(ctFont.sizeOfStrikeArray(), 1);
    assertEquals(true, ctFont.getStrikeArray(0).getVal());
    assertEquals(true, ctFont.getStrikeArray(0).getVal());
}
Also used : CTBooleanProperty(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBooleanProperty) CTFont(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont) Test(org.junit.Test)

Aggregations

CTFont (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont)16 Test (org.junit.Test)14 CTColor (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor)5 CTBooleanProperty (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBooleanProperty)3 POIXMLException (org.apache.poi.POIXMLException)2 CTFontSize (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontSize)2 CTIntProperty (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTIntProperty)2 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1 SXSSFWorkbook (org.apache.poi.xssf.streaming.SXSSFWorkbook)1 XmlException (org.apache.xmlbeans.XmlException)1 CTBorder (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder)1 CTFill (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill)1 CTFontName (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontName)1 CTFontScheme (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontScheme)1 CTUnderlineProperty (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTUnderlineProperty)1 CTVerticalAlignFontProperty (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTVerticalAlignFontProperty)1 CTFontImpl (org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontImpl)1