[]
        
(Showing Draft Content)

ILegendEntry

Interface ILegendEntry


public interface ILegendEntry
Represents a legend entry in a chart legend.

An ILegendEntry identifies a single entry displayed in a chart legend. Use this interface to access the entry's font and chart formatting, or to remove the entry from the legend. Legend entries are available from the ILegendEntries collection returned by ILegend.getLegendEntries().


 worksheet.getRange("A1:B3").setValue(new Object[][] {
     {"Region", "Sales"},
     {"North", 100},
     {"South", 200}
 });
 IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 200, 20, 300, 200);
 shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
 ILegendEntry legendEntry = shape.getChart().getLegend().getLegendEntries().get(0);
 legendEntry.getFont().setItalic(true);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes this legend entry.
    Gets the IFontFormat object that represents the font settings of the legend entry.
    Gets the chart format of the legend entry.
    Gets the parent legend that contains this legend entry.
  • Method Details

    • getFont

      IFontFormat getFont()
      Gets the IFontFormat object that represents the font settings of the legend entry.

      Use the returned IFontFormat object to read or modify the font applied to the legend entry text.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 10},
           {"B", 20}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.setSourceData(worksheet.getRange("A1:B3"));
       ILegendEntry legendEntry = chart.getLegend().getLegendEntries().get(0);
       IFontFormat font = legendEntry.getFont();
       font.setBold(true);
       
      Returns:
      The IFontFormat object for the legend entry font.
    • getFormat

      IChartFormat getFormat()
      Gets the chart format of the legend entry.

      Use the returned IChartFormat object to access and modify the fill, line, and other formatting settings of the legend entry.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 10},
           {"B", 20}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.setSourceData(worksheet.getRange("A1:B3"));
       ILegendEntry legendEntry = chart.getLegend().getLegendEntries().get(0);
       IChartFormat format = legendEntry.getFormat();
       format.getFill().getColor().setRGB(Color.GetRed());
       
      Returns:
      The IChartFormat object that represents the formatting of the legend entry.
    • getParent

      ILegend getParent()
      Gets the parent legend that contains this legend entry.
      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 12},
           {"Feb", 18},
           {"Mar", 15}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
       ILegendEntry legendEntry = chart.getLegend().getLegendEntries().get(0);
       ILegend legend = legendEntry.getParent();
       
      Returns:
      The parent ILegend object that contains this legend entry.
    • delete

      void delete()
      Deletes this legend entry.

      Use this method to mark the current legend entry as deleted.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 10},
           {"B", 20}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.setSourceData(worksheet.getRange("A1:B3"));
       ILegendEntry legendEntry = chart.getLegend().getLegendEntries().get(0);
       legendEntry.delete();