[]
Use this interface to read or modify the formatting of text associated with drawing-related objects. It provides access to font color through IColorFormat and to common text style settings such as bold, italic, underline, strikethrough, subscript, superscript, and theme font.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
chart.setHasDataTable(true);
IFontFormat font = chart.getDataTable().getFont();
font.setBold(true);
font.getColor().setRGB(Color.GetBlue());
booleangetBold()getColor()booleangetName()doublegetSize()booleanbooleanbooleanvoidsetBold(boolean value) voidsetItalic(boolean value) voidvoidsetSize(double value) voidsetStrikethrough(boolean value) voidsetSubscript(boolean value) voidsetSuperscript(boolean value) voidsetThemeFont(ThemeFont value) voidsetUnderline(TextUnderlineType value) Returns the IColorFormat object that represents the color of the text associated with this font format. Use the returned object to read or modify the text color, such as an RGB color or a theme-based color.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
chart.setHasDataTable(true);
IColorFormat colorFormat = chart.getDataTable().getFont().getColor();
colorFormat.setRGB(Color.GetBlue());
IColorFormat object that represents the color of the represented text.This property indicates whether bold formatting is applied to the text represented by this IFontFormat object. Use setBold(boolean) to change the bold state.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
chart.setHasDataTable(true);
IFontFormat font = chart.getDataTable().getFont();
boolean bold = font.getBold();
true if the represented text is bold; otherwise, false.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
chart.setHasDataTable(true);
IFontFormat font = chart.getDataTable().getFont();
font.setBold(true);
value - true if the represented text is bold; otherwise, false.This property indicates whether italic formatting is applied to the text represented by this IFontFormat object. Use setItalic(boolean) to change the italic state.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
chart.setHasDataTable(true);
chart.getDataTable().getFont().setItalic(true);
boolean italic = chart.getDataTable().getFont().getItalic();
true if the represented text is italicized; otherwise, false.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
chart.setHasDataTable(true);
chart.getDataTable().getFont().setItalic(true);
value - true if the represented text is italicized; otherwise, false.Returns the font name currently applied to this text formatting. Use setName(String) to change the font name.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.getTextFrame().getTextRange().setText("Hello");
shape.getTextFrame().getTextRange().getFont().setName("Arial");
String fontName = shape.getTextFrame().getTextRange().getFont().getName();
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.getTextFrame().getTextRange().setText("Hello");
shape.getTextFrame().getTextRange().getFont().setName("Arial");
value - The font name used for the represented text.The returned value specifies the font size applied to the represented text.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 40, 40, 100, 100);
shape.getTextFrame().getTextRange().setText("Hello");
shape.getTextFrame().getTextRange().getFont().setSize(18);
double fontSize = shape.getTextFrame().getTextRange().getFont().getSize();
The returned value specifies the font size applied to the represented text.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 40, 40, 100, 100);
shape.getTextFrame().getTextRange().setText("Hello");
shape.getTextFrame().getTextRange().getFont().setSize(18);
value - The font size, in points.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.getTextFrame().getTextRange().setText("Hello");
shape.getTextFrame().getTextRange().getFont().setStrikethrough(true);
boolean strikethrough = shape.getTextFrame().getTextRange().getFont().getStrikethrough();
true if the represented text has a strike through it; false otherwise.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.getTextFrame().getTextRange().setText("Hello");
shape.getTextFrame().getTextRange().getFont().setStrikethrough(true);
value - true if the represented text has a strike through it; false otherwise.Use this method to determine whether the current character formatting applies subscript to the text.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.getTextFrame().getTextRange().setText("H2O");
shape.getTextFrame().getTextRange().getFont().setSubscript(true);
boolean subscript = shape.getTextFrame().getTextRange().getFont().getSubscript();
true if the represented text is a subscript; otherwise, false.Use this method to set whether the current character formatting applies subscript to the text.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.getTextFrame().getTextRange().setText("H2O");
shape.getTextFrame().getTextRange().getFont().setSubscript(true);
value - true if the represented text is a subscript; otherwise, false.Returns whether superscript formatting is applied to the represented text. The default value is false.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.getTextFrame().getTextRange().setText("Hello");
shape.getTextFrame().getTextRange().getFont().setSuperscript(true);
boolean superscript = shape.getTextFrame().getTextRange().getFont().getSuperscript();
true if the represented text is formatted as superscript; false otherwise.Sets whether superscript formatting is applied to the represented text. The default value is false.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.getTextFrame().getTextRange().setText("Hello");
shape.getTextFrame().getTextRange().getFont().setSuperscript(true);
value - true if the represented text is formatted as superscript; false otherwise.Returns a TextUnderlineType value that describes how the text is underlined.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.getTextFrame().getTextRange().setText("Hello");
shape.getTextFrame().getTextRange().getFont().setUnderline(TextUnderlineType.Single);
TextUnderlineType underline = shape.getTextFrame().getTextRange().getFont().getUnderline();
Use this method to apply one of the underline styles defined by TextUnderlineType, such as single, double, or wavy underline.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.getTextFrame().getTextRange().setText("Hello");
shape.getTextFrame().getTextRange().getFont().setUnderline(TextUnderlineType.Single);
value - The underline style to apply.Use this method to determine whether the object uses the major theme font, minor theme font, or no theme font.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.getTextFrame().getTextRange().setText("Hello");
shape.getTextFrame().getTextRange().getFont().setThemeFont(ThemeFont.Major);
ThemeFont themeFont = shape.getTextFrame().getTextRange().getFont().getThemeFont();
ThemeFont in the applied font scheme that is associated with the specified object. Returns ThemeFont.None if no theme font is applied.Use this method to apply a theme-based font choice, such as the major or minor theme font, to the represented text.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.getTextFrame().getTextRange().setText("Hello");
shape.getTextFrame().getTextRange().getFont().setThemeFont(ThemeFont.Minor);
value - The theme font to apply to the represented text.