use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont 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());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.
the class TestXSSFFont method testScheme.
@Test
public void testScheme() {
CTFont ctFont = CTFont.Factory.newInstance();
CTFontScheme scheme = ctFont.addNewScheme();
scheme.setVal(STFontScheme.MAJOR);
ctFont.setSchemeArray(0, scheme);
XSSFFont font = new XSSFFont(ctFont);
assertEquals(FontScheme.MAJOR, font.getScheme());
font.setScheme(FontScheme.NONE);
assertEquals(STFontScheme.NONE, ctFont.getSchemeArray(0).getVal());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.
the class TestXSSFFont method testFontName.
@Test
public void testFontName() {
CTFont ctFont = CTFont.Factory.newInstance();
CTFontName fname = ctFont.addNewName();
fname.setVal("Arial");
ctFont.setNameArray(0, fname);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals("Arial", xssfFont.getFontName());
xssfFont.setFontName("Courier");
assertEquals("Courier", ctFont.getNameArray(0).getVal());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.
the class TestXSSFFont method testItalic.
@Test
public void testItalic() {
CTFont ctFont = CTFont.Factory.newInstance();
CTBooleanProperty bool = ctFont.addNewI();
bool.setVal(false);
ctFont.setIArray(0, bool);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(false, xssfFont.getItalic());
xssfFont.setItalic(true);
assertEquals(ctFont.sizeOfIArray(), 1);
assertEquals(true, ctFont.getIArray(0).getVal());
assertEquals(true, ctFont.getIArray(0).getVal());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.
the class TestXSSFFont method testCharSet.
@Test
public void testCharSet() throws IOException {
CTFont ctFont = CTFont.Factory.newInstance();
CTIntProperty prop = ctFont.addNewCharset();
prop.setVal(FontCharset.ANSI.getValue());
ctFont.setCharsetArray(0, prop);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(Font.ANSI_CHARSET, xssfFont.getCharSet());
xssfFont.setCharSet(FontCharset.DEFAULT);
assertEquals(FontCharset.DEFAULT.getValue(), ctFont.getCharsetArray(0).getVal());
// Try with a few less usual ones:
// Set with the Charset itself
xssfFont.setCharSet(FontCharset.RUSSIAN);
assertEquals(FontCharset.RUSSIAN.getValue(), xssfFont.getCharSet());
// And set with the Charset index
xssfFont.setCharSet(FontCharset.ARABIC.getValue());
assertEquals(FontCharset.ARABIC.getValue(), xssfFont.getCharSet());
xssfFont.setCharSet((byte) (FontCharset.ARABIC.getValue()));
assertEquals(FontCharset.ARABIC.getValue(), xssfFont.getCharSet());
// This one isn't allowed
assertEquals(null, FontCharset.valueOf(9999));
try {
xssfFont.setCharSet(9999);
fail("Shouldn't be able to set an invalid charset");
} catch (POIXMLException e) {
}
// Now try with a few sample files
// Normal charset
XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("Formatting.xlsx");
assertEquals(0, wb1.getSheetAt(0).getRow(0).getCell(0).getCellStyle().getFont().getCharSet());
wb1.close();
// GB2312 charact set
XSSFWorkbook wb2 = XSSFTestDataSamples.openSampleWorkbook("49273.xlsx");
assertEquals(134, wb2.getSheetAt(0).getRow(0).getCell(0).getCellStyle().getFont().getCharSet());
wb2.close();
}
Aggregations