共用方式為


ChartSheetBase.ApplyDataLabels Method

Definition

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

public void ApplyDataLabels (Microsoft.Office.Interop.Excel.XlDataLabelsType type, object legendKey, object autoText, object hasLeaderLines, object showSeriesName, object showCategoryName, object showValue, object showPercentage, object showBubbleSize, object separator);
member this.ApplyDataLabels : Microsoft.Office.Interop.Excel.XlDataLabelsType * obj * obj * obj * obj * obj * obj * obj * obj * obj -> unit
Public Sub ApplyDataLabels (Optional type As XlDataLabelsType, Optional legendKey As Object, Optional autoText As Object, Optional hasLeaderLines As Object, Optional showSeriesName As Object, Optional showCategoryName As Object, Optional showValue As Object, Optional showPercentage As Object, Optional showBubbleSize As Object, Optional separator As Object)

Parameters

type
XlDataLabelsType

The type of data label to apply.

legendKey
Object

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

autoText
Object

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

hasLeaderLines
Object

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

showSeriesName
Object

The series name for the data label.

showCategoryName
Object

The category name for the data label.

showValue
Object

The value for the data label.

showPercentage
Object

The percentage for the data label.

showBubbleSize
Object

The bubble size for the data label.

separator
Object

The separator for the data label.

Examples

The following code example uses the ApplyDataLabels method to show the data values in the current Microsoft.Office.Tools.Excel.ChartSheetBase.

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

    this.SetSourceData(Globals.Sheet1.Range["A1", "B5"],
        Excel.XlRowCol.xlColumns);
    this.ApplyDataLabels(
        Excel.XlDataLabelsType.xlDataLabelsShowValue,
        true, false, false, true, true, false, 
        true);
}
Private Sub ShowDataLabels()
    Globals.Sheet1.Range("A1", "A5").Value2 = 22
    Globals.Sheet1.Range("B1", "B5").Value2 = 55

    Me.SetSourceData(Globals.Sheet1.Range("A1", "B5"), _
        Excel.XlRowCol.xlColumns)
    Me.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowValue, _
        AutoText:=True, HasLeaderLines:=False, ShowSeriesName:=False, _
        ShowCategoryName:=True, ShowValue:=True, ShowPercentage:=False, _
        ShowBubbleSize:=True)
End Sub

Remarks

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to