[]
        
(Showing Draft Content)

IFontFormat

Interface IFontFormat


public interface IFontFormat
Represents font attributes, such as font name, font size, color, and text styles, for an object.

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());
 
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Gets the boolean property that indicates whether the represented text is bold.
    Gets the color format.
    boolean
    Gets the boolean property that indicates whether the represented text is italicized.
    Gets the font name to use for the represented text.
    double
    Gets the size of the font in points.
    boolean
    Gets the boolean property that indicates whether the represented text has a strike through it.
    boolean
    Gets the boolean property that indicates whether the represented text is a subscript.
    boolean
    Gets the boolean property that indicates whether the represented text is a superscript.
    Gets the theme font in the applied font scheme that is associated with the specified object.
    Gets the underline style of the represented text.
    void
    setBold(boolean value)
    Sets the boolean property that indicates whether the represented text is bold.
    void
    setItalic(boolean value)
    Sets the boolean property that indicates whether the represented text is italicized.
    void
    setName(String value)
    Sets the font name to use for the represented text.
    void
    setSize(double value)
    Sets the size of the font in points.
    void
    setStrikethrough(boolean value)
    Sets the boolean property that indicates whether the represented text has a strike through it.
    void
    setSubscript(boolean value)
    Sets the boolean property that indicates whether the represented text is a subscript.
    void
    setSuperscript(boolean value)
    Sets the boolean property that indicates whether the represented text is a superscript.
    void
    Sets the theme font in the applied font scheme that is associated with the specified object.
    void
    Sets the underline style of the represented text.
  • Method Details

    • getColor

      IColorFormat getColor()
      Gets the color format.

      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());
       
      Returns:
      The IColorFormat object that represents the color of the represented text.
    • getBold

      boolean getBold()
      Gets the boolean property that indicates whether the represented text is bold.

      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();
       
      Returns:
      true if the represented text is bold; otherwise, false.
    • setBold

      void setBold(boolean value)
      Sets the boolean property that indicates whether the represented text is bold.
      
       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);
       
      Parameters:
      value - true if the represented text is bold; otherwise, false.
    • getItalic

      boolean getItalic()
      Gets the boolean property that indicates whether the represented text is italicized.

      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();
       
      Returns:
      true if the represented text is italicized; otherwise, false.
    • setItalic

      void setItalic(boolean value)
      Sets the boolean property that indicates whether the represented text is italicized.
      
       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);
       
      Parameters:
      value - true if the represented text is italicized; otherwise, false.
    • getName

      String getName()
      Gets the font name to use for the represented text.

      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();
       
      Returns:
      The font name used for the represented text.
    • setName

      void setName(String value)
      Sets the font name to use for the represented text.
      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
       shape.getTextFrame().getTextRange().setText("Hello");
       shape.getTextFrame().getTextRange().getFont().setName("Arial");
       
      Parameters:
      value - The font name used for the represented text.
    • getSize

      double getSize()
      Gets the size of the font in points.

      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();
       
      Returns:
      The font size, in points.
    • setSize

      void setSize(double value)
      Sets the size of the font in points.

      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);
       
      Parameters:
      value - The font size, in points.
    • getStrikethrough

      boolean getStrikethrough()
      Gets the boolean property that indicates whether the represented text has a strike through it.
      
       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();
       
      Returns:
      true if the represented text has a strike through it; false otherwise.
    • setStrikethrough

      void setStrikethrough(boolean value)
      Sets the boolean property that indicates whether the represented text has a strike through it.
      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
       shape.getTextFrame().getTextRange().setText("Hello");
       shape.getTextFrame().getTextRange().getFont().setStrikethrough(true);
       
      Parameters:
      value - true if the represented text has a strike through it; false otherwise.
    • getSubscript

      boolean getSubscript()
      Gets the boolean property that indicates whether the represented text is a subscript.

      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();
       
      Returns:
      true if the represented text is a subscript; otherwise, false.
    • setSubscript

      void setSubscript(boolean value)
      Sets the boolean property that indicates whether the represented text is a subscript.

      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);
       
      Parameters:
      value - true if the represented text is a subscript; otherwise, false.
    • getSuperscript

      boolean getSuperscript()
      Gets the boolean property that indicates whether the represented text is a superscript.

      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();
       
      Returns:
      true if the represented text is formatted as superscript; false otherwise.
    • setSuperscript

      void setSuperscript(boolean value)
      Sets the boolean property that indicates whether the represented text is a superscript.

      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);
       
      Parameters:
      value - true if the represented text is formatted as superscript; false otherwise.
    • getUnderline

      TextUnderlineType getUnderline()
      Gets the underline style of the represented text.

      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();
       
      Returns:
      The underline style of the represented text.
    • setUnderline

      void setUnderline(TextUnderlineType value)
      Sets the underline style of the represented text.

      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);
       
      Parameters:
      value - The underline style to apply.
    • getThemeFont

      ThemeFont getThemeFont()
      Gets the theme font in the applied font scheme that is associated with the specified object.

      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();
       
      Returns:
      The ThemeFont in the applied font scheme that is associated with the specified object. Returns ThemeFont.None if no theme font is applied.
    • setThemeFont

      void setThemeFont(ThemeFont value)
      Sets the theme font in the applied font scheme that is associated with the specified object.

      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);
       
      Parameters:
      value - The theme font to apply to the represented text.