Font font2Base = new Font("'Times New Roman'", FontStyle.REGULAR, (float) 13.95, new Color("#ff3333"),
TextLinePosition.THROUGHUNDER);
Font font3Base = new Font("SimSun", FontStyle.BOLD, 8, Color.BLACK, TextLinePosition.REGULAR);
Font font4Base = new Font("Arial", FontStyle.REGULAR, 10, Color.BLACK, TextLinePosition.UNDER);
try {
SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
.getTestResourceAsStream(filename));
Table table = doc.getTableByName("A");
Cell cell1 = table.getCellByPosition("A2");
CellStyleHandler handler1 = cell1.getStyleHandler();
Font font1 = handler1.getFont(Document.ScriptType.WESTERN);
Assert.assertEquals(font1Base, font1);
Cell cell2 = table.getCellByPosition("A3");
CellStyleHandler handler2 = cell2.getStyleHandler();
Font font2 = handler2.getFont(Document.ScriptType.WESTERN);
Assert.assertEquals(font2Base, font2);
Cell cell3 = table.getCellByPosition("A4");
CellStyleHandler handler3 = cell3.getStyleHandler();
Font font3 = handler3.getFont(Document.ScriptType.CJK);
Assert.assertEquals(font3Base, font3);
Font font4 = handler3.getFont(Document.ScriptType.WESTERN);
Assert.assertEquals(font4Base, font4);
Cell cell5 = table.getCellByPosition("B2");
cell5.getStyleHandler().setFont(font1Base);
cell5.setStringValue("Arial Italic black 10");
Assert.assertEquals(font1Base, cell5.getStyleHandler().getFont(Document.ScriptType.WESTERN));
Cell cell6 = table.getCellByPosition("B3");
// font2Base.setLocale();
cell6.getStyleHandler()
.setFont(font2Base, new Locale(Locale.ENGLISH.getLanguage(), Locale.US.getCountry()));
cell6.setStringValue("Times New Roman, Regular, 13.9, Red");
Assert.assertEquals(font2Base, cell6.getStyleHandler().getFont(Document.ScriptType.WESTERN));
Cell cell7 = table.getCellByPosition("B4");
cell7.getStyleHandler().setFont(font3Base,
new Locale(Locale.CHINESE.getLanguage(), Locale.CHINA.getCountry()));
cell7.getStyleHandler()
.setFont(font4Base, new Locale(Locale.ENGLISH.getLanguage(), Locale.US.getCountry()));
cell7.setStringValue("SimSun BOLD 8 BLACK");
Assert.assertEquals(font3Base, cell7.getStyleHandler().getFont(Document.ScriptType.CJK));
Assert.assertEquals(font4Base, cell7.getStyleHandler().getFont(Document.ScriptType.WESTERN));
doc.save(ResourceUtilities.newTestOutputFile("testFontOutput.ods"));
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
}