Export (0) Print
Expand All
Expand Minimize

Chart.ApplyDataLabels Method (2007 System)

Applies data labels to a point, a series, or all the series in a Chart control.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

public void ApplyDataLabels(
	XlDataLabelsType Type,
	Object LegendKey,
	Object AutoText,
	Object HasLeaderLines,
	Object ShowSeriesName,
	Object ShowCategoryName,
	Object ShowValue,
	Object ShowPercentage,
	Object ShowBubbleSize,
	Object Separator
)

Parameters

Type
Type: XlDataLabelsType

XlDataLabelsType. The type of data label to apply.

LegendKey
Type: System.Object

true to show the legend key next to the point. The default value is false.

AutoText
Type: System.Object

true if the object automatically generates appropriate text based on content.

HasLeaderLines
Type: System.Object

For the Chart and Series objects, true if the series has leader lines.

ShowSeriesName
Type: System.Object

The series name for the data label.

ShowCategoryName
Type: System.Object

The category name for the data label.

ShowValue
Type: System.Object

The value for the data label.

ShowPercentage
Type: System.Object

The percentage for the data label.

ShowBubbleSize
Type: System.Object

The bubble size for the data label.

Separator
Type: System.Object

The separator for the data label.

Optional Parameters

For information on optional parameters, see The Variable missing and Optional Parameters in Office Solutions.

The following code example creates a Chart and then uses the ApplyDataLabels method to display data labels with the series names on the chart.

private void DisplayLabels()
{
    this.Range["A1", "A5"].Value2 = 22;
    this.Range["B1", "B5"].Value2 = 55;

    Microsoft.Office.Tools.Excel.Chart chart1 =
        this.Controls.AddChart(this.Range["D2", "H20"], 
        "chart1");

    chart1.SetSourceData(this.Range["A1", "B5"], 
        Excel.XlRowCol.xlColumns);
    chart1.ChartType = Excel.XlChartType.xlBarClustered;

    chart1.ApplyDataLabels(
        Excel.XlDataLabelsType.xlDataLabelsShowLabel,
        false, false, false, true, false, false, false, 
        false, false);
}

Community Additions

ADD
Show:
© 2014 Microsoft