The most simple method to define font settings is to create a font object, and set it to a cell object. The below code snippet defines a font object to describe "Arial" italic font with size "12pt" and black color, and then set it to a cell. The font will work for western characters by default.
SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument(); Table table = document.getTableByName("Sheet1"); Font font = newFont("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 12, Color.BLACK); Cell cell = table.getCellByPosition("A1");
The most simple method to get font settings of western characters is:
Font theFont = cell.getFont(); double size = theFont.getSize(); String fontName = theFont.getFamilyName(); StyleTypeDefinitions.FontStyle fontStyle = theFont.getFontStyle(); Color fontColor = theFont.getColor();
CellStyleHandler can help you to achieve advanced functions. In Open Document Format, there can be different font settings for different script types. For example, a font setting for English characters and another font setting for Chinese characters. If you want to define the font setting for other script types, you can reference to below codes. The below code snippet defines a font for Chinese characters.
Apache "ODF Toolkit" is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator.
Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and
decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is
not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has
yet to be fully endorsed by the ASF.