[]
        
(Showing Draft Content)

IDataTable

Interface IDataTable


public interface IDataTable
Represents a chart data table.

Use this interface to access or format the data table displayed beneath a chart, including its font, border options, and legend key display.


 worksheet.getRange("A1:C3").setValue(new Object[][] {
     {"Item", "Estimated", "Actual"},
     {"Income", 63300, 57450},
     {"Expenses", 54500, 49630}
 });
 IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
 chart.getSeriesCollection().add(worksheet.getRange("A1:C3"));
 chart.setHasDataTable(true);
 IDataTable dataTable = chart.getDataTable();
 
  • Method Details

    • getFont

      IFontFormat getFont()
      Gets the IFontFormat object for the chart data table.

      Use the returned font format to read or modify font settings for the text displayed in the data table.

      
       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("B1:B3"), RowCol.Columns, true, true);
       chart.setHasDataTable(true);
       IFontFormat font = chart.getDataTable().getFont();
       font.getColor().setRGB(Color.GetRed());
       
      Returns:
      The IFontFormat object for the chart data table.
    • getFormat

      IChartFormat getFormat()
      Gets the format of the chart data table.

      Use the returned IChartFormat object to access the fill and line formatting settings of the chart data table.

      
       worksheet.getRange("A1:C3").setValue(new Object[][] {
           {"Month", "Sales", "Profit"},
           {"Jan", 100, 20},
           {"Feb", 120, 25}
       });
       worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200)
           .getChart().getSeriesCollection().add(worksheet.getRange("A1:C3"));
       worksheet.getShapes().get(0).getChart().setHasDataTable(true);
       worksheet.getShapes().get(0).getChart().getDataTable().getFormat().getLine().setWeight(1.5);
       
      Returns:
      The IChartFormat object for the chart data table; see IChartFormat.
    • getParent

      IChart getParent()
      Gets the parent IChart of the data table.

      Use this method to access the chart that owns the current data table.

      
       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);
       IChart parentChart = chart.getDataTable().getParent();
       
      Returns:
      The parent of the data table.
    • getShowLegendKey

      boolean getShowLegendKey()
      Gets whether legend keys are shown in the chart data table.

      This property indicates whether the chart data table displays a legend key for each series. The default value is true.

      
       worksheet.getRange("A1:C3").setValue(new Object[][] {
           {"Month", "Sales", "Target"},
           {"Jan", 100, 90},
           {"Feb", 120, 110}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:C3"), RowCol.Columns, true, true);
       chart.setHasDataTable(true);
       boolean showLegendKey = chart.getDataTable().getShowLegendKey();
       
      Returns:
      true if legend keys are shown in the chart data table; otherwise, false.
    • setShowLegendKey

      void setShowLegendKey(boolean value)
      Sets whether legend keys are displayed in the chart data table.

      Use this method to show or hide the legend key for each series in the chart data table. The default setting is true.

      
       worksheet.getRange("A1:C3").setValue(new Object[][] {
           {"Item", "Planned", "Actual"},
           {"Sales", 120, 135},
           {"Cost", 80, 75}
       });
       com.grapecity.documents.excel.drawing.IChart chart = worksheet.getShapes()
           .addChart(com.grapecity.documents.excel.drawing.ChartType.ColumnClustered, 20, 20, 300, 200)
           .getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:C3"));
       chart.setHasDataTable(true);
       chart.getDataTable().setShowLegendKey(false);
       
      Parameters:
      value - true to display legend keys in the chart data table; otherwise, false.
    • getHasBorderHorizontal

      boolean getHasBorderHorizontal()
      Gets whether the chart data table displays horizontal cell borders.

      This property indicates whether horizontal border lines are shown between rows in the chart data table. The default value is true.

      
       worksheet.getRange("A1:C3").setValue(new Object[][] {
           {"Item", "Planned", "Actual"},
           {"Sales", 120, 135},
           {"Cost", 80, 75}
       });
       com.grapecity.documents.excel.drawing.IChart chart = worksheet.getShapes()
           .addChart(com.grapecity.documents.excel.drawing.ChartType.ColumnClustered, 20, 20, 300, 200)
           .getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:C3"));
       chart.setHasDataTable(true);
       boolean hasHorizontalBorder = chart.getDataTable().getHasBorderHorizontal();
       
      Returns:
      true if the chart data table displays horizontal cell borders; otherwise, false.
    • setHasBorderHorizontal

      void setHasBorderHorizontal(boolean value)
      Sets whether the chart data table displays horizontal cell borders.

      Use this method to show or hide horizontal border lines between rows in the chart data table.

      
       worksheet.getRange("A1:C3").setValue(new Object[][] {
           {"Item", "Planned", "Actual"},
           {"Sales", 120, 135},
           {"Cost", 80, 75}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:C3"));
       chart.setHasDataTable(true);
       chart.getDataTable().setHasBorderHorizontal(false);
       
      Parameters:
      value - true to display horizontal cell borders in the chart data table; otherwise, false.
    • getHasBorderVertical

      boolean getHasBorderVertical()
      Gets whether the chart data table has vertical cell borders.

      The default value is true. This property indicates whether vertical border lines are displayed between cells in the chart data table.

      
       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("B1:B3"), RowCol.Columns, true, true);
       chart.setHasDataTable(true);
       chart.getDataTable().setHasBorderVertical(false);
       boolean hasBorderVertical = chart.getDataTable().getHasBorderVertical();
       
      Returns:
      true if the chart data table has vertical cell borders; otherwise, false.
    • setHasBorderVertical

      void setHasBorderVertical(boolean value)
      Sets whether the chart data table has vertical cell borders.

      Set this property to true to display vertical border lines between cells in the chart data table, or false to hide them.

      
       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("B1:B3"), RowCol.Columns, true, true);
       chart.setHasDataTable(true);
       chart.getDataTable().setHasBorderVertical(false);
       
      Parameters:
      value - true to display vertical cell borders in the chart data table; otherwise, false.
    • getHasBorderOutline

      boolean getHasBorderOutline()
      Gets whether the chart data table has outline borders.

      The default value is true. This property indicates whether an outer border is displayed around the chart data table.

      
       worksheet.getRange("A1:C3").setValue(new Object[][] {
           {"Month", "Sales", "Profit"},
           {"Jan", 100, 20},
           {"Feb", 120, 25}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:C3"));
       chart.setHasDataTable(true);
       boolean hasBorderOutline = chart.getDataTable().getHasBorderOutline();
       
      Returns:
      true if the chart data table has outline borders; otherwise, false.
    • setHasBorderOutline

      void setHasBorderOutline(boolean value)
      Sets whether the chart data table has outline borders.

      Use this property to show or hide the outer border around the chart data table.

      
       worksheet.getRange("A1:C3").setValue(new Object[][] {
           {"Month", "Sales", "Profit"},
           {"Jan", 100, 20},
           {"Feb", 120, 25}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:C3"));
       chart.setHasDataTable(true);
       chart.getDataTable().setHasBorderOutline(false);
       
      Parameters:
      value - true to display outline borders for the chart data table; otherwise, false.
    • delete

      void delete()
      Deletes this chart data table.

      After this method is called, the data table is removed from its parent IChart.

      
       worksheet.getRange("A1:C3").setValue(new Object[][] {
           {"Month", "Sales", "Profit"},
           {"Jan", 100, 20},
           {"Feb", 120, 25}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:C3"));
       chart.setHasDataTable(true);
       chart.getDataTable().delete();