[]
        
(Showing Draft Content)

ILegendEntries

Interface ILegendEntries

All Superinterfaces:
Iterable<ILegendEntry>

public interface ILegendEntries extends Iterable<ILegendEntry>
Represents the collection of legend entries in a chart legend.

Use this interface to access individual ILegendEntry objects in a legend, iterate through the entries, and retrieve the legend that owns the collection. This collection is 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);
 ILegendEntries legendEntries = shape.getChart().getLegend().getLegendEntries();
 ILegendEntry firstEntry = legendEntries.get(0);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    get(int index)
    Gets the legend entry at the specified index.
    int
    Gets the number of legend entries in the collection.
    Gets the parent legend that contains this legend entry collection.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • getCount

      int getCount()
      Gets the number of legend entries in the collection.

      Use this method to determine how many ILegendEntry objects are contained in the legend for a chart.

      
       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"));
       int count = chart.getLegend().getLegendEntries().getCount();
       
      Returns:
      The number of legend entries in the collection.
    • getParent

      ILegend getParent()
      Gets the parent legend that contains this legend entry collection.

      Use this method to access the ILegend object that owns the current ILegendEntries collection.

      
       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"));
       ILegendEntries legendEntries = chart.getLegend().getLegendEntries();
       ILegend legend = legendEntries.getParent();
       
      Returns:
      The parent ILegend object that contains this legend entry collection.
    • get

      ILegendEntry get(int index)
      Gets the legend entry at the specified index.

      Use this method to access a single ILegendEntry object from the current legend entry collection.

      
       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();
       
      Parameters:
      index - The zero-based index of the legend entry to retrieve.
      Returns:
      The ILegendEntry object at the specified index.