Table of Contents

Interface IChartDataLabels

Namespace
Spire.Xls.Core
Assembly
Spire.XLS.dll

Represents a collection of chart data labels.

public interface IChartDataLabels : IChartTextArea, IFont, IExcelApplication, IOptimizedUpdate
Inherited Members

Properties

Delimiter

Delimeter. The following code illustrates how to access the IChartDataLabels and set delimiter for data labels:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
Chart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C3"];

//Set chart type
chart.ChartType = ExcelChartType.ColumnClustered;

//Get the chart serie
IChartSerie serie = chart.Series[0];

//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;

//Set ' ' symbol as separator for data labels
dataLabels.HasValue = true;
dataLabels.HasSeriesName = true;
dataLabels.Delimiter =" ";

//Save to file
workbook.SaveToFile("Chart.xlsx");
string Delimiter { get; set; }

Property Value

string

HasBubbleSize

Indicates whether bubble size is in data labels. The following code illustrates how to access the IChartDataLabels and set to shows the bubble sizes:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
Chart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C3"];

//Set chart type
chart.ChartType = ExcelChartType.Bubble;

//Get the chart serie
IChartSerie serie = chart.Series[0];

//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;

//Set the data label to show the bubble sizes
dataLabels.HasBubbleSize = true;

//Save to file
workbook.SaveToFile("Chart.xlsx");
bool HasBubbleSize { get; set; }

Property Value

bool

HasCategoryName

Indicates whether category name is in data labels. The following code illustrates how to access the IChartDataLabels and set to shows the categories:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
Chart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C3"];

//Set chart type
chart.ChartType = ExcelChartType.ColumnClustered;

//Get the chart serie
IChartSerie serie = chart.Series[0];

//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;

//Set the data label to show the category names
dataLabels.HasCategoryName = true;

//Save to file
workbook.SaveToFile("Chart.xlsx");
bool HasCategoryName { get; set; }

Property Value

bool

HasLegendKey

Indicates whether legend key is in data labels. The following code illustrates how to access the IChartDataLabels and set to shows the legend keys:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
Chart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C3"];

//Set chart type
chart.ChartType = ExcelChartType.ColumnClustered;

//Get the chart serie
IChartSerie serie = chart.Series[0];

//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;

//Set the data label to show the legend key
dataLabels.HasValue = true;
dataLabels.HasLegendKey = true;

//Save to file
workbook.SaveToFile("Chart.xlsx");
bool HasLegendKey { get; set; }

Property Value

bool

HasPercentage

Indicates whether percentage is in data labels. The following code illustrates how to access the IChartDataLabels and set to shows the percentage values:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
Chart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C2"];

//Set chart type
chart.ChartType = ExcelChartType.Pie;

//Get the chart serie
IChartSerie serie = chart.Series[0];

//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;

//Set the data label to show the percentage values
dataLabels.HasPercentage = true;

//Save to file
workbook.SaveToFile("Chart.xlsx");
bool HasPercentage { get; set; }

Property Value

bool

HasSeriesName

Indicates whether series name is in data labels. The following code illustrates how to access the IChartDataLabels and set to shows the serie name:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
Chart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C3"];

//Set chart type
chart.ChartType = ExcelChartType.ColumnClustered;

//Get the chart serie
IChartSerie serie = chart.Series[0];

//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;

//Set the data label to show the serie name
dataLabels.HasSeriesName = true;

//Save to file
workbook.SaveToFile("Chart.xlsx");
bool HasSeriesName { get; set; }

Property Value

bool

HasValue

Indicates whether value is in data labels. The following code illustrates how to access the IChartDataLabels and set to shows the values:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
Chart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C3"];

//Set chart type
chart.ChartType = ExcelChartType.ColumnClustered;

//Get the chart serie
IChartSerie serie = chart.Series[0];

//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;

//Set the data label to show the values
dataLabels.HasValue = true;

//Save to file
workbook.SaveToFile("Chart.xlsx");
bool HasValue { get; set; }

Property Value

bool

IsResizeShapeToFitText

bool IsResizeShapeToFitText { get; set; }

Property Value

bool

IsTextWrapped

bool IsTextWrapped { get; set; }

Property Value

bool

NumberFormat

Represents trend line label number format.

string NumberFormat { get; set; }

Property Value

string

Position

Represents data labels position. The following code illustrates how to access the IChartDataLabels and set to the position for labels:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
Chart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C2"];

//Set chart type
chart.ChartType = ExcelChartType.Pie;

//Get the chart serie
IChartSerie serie = chart.Series[0];

//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;

//Set the data label to show the leader lines
dataLabels.HasValue = true;
dataLabels.Position = DataLabelPositionType.Outside;

//Save to file
workbook.SaveToFile("Chart.xlsx");
DataLabelPositionType Position { get; set; }

Property Value

DataLabelPositionType

ShowLeaderLines

Indicates whether Leader Lines is in data labels. The following code illustrates how to access the IChartDataLabels and set to leader lines to show:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
Chart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C2"];

//Set chart type
chart.ChartType = ExcelChartType.Pie;

//Get the chart serie
IChartSerie serie = chart.Series[0];

//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;

//Set the data label to show the leader lines
dataLabels.HasValue = true;
dataLabels.Position = DataLabelPositionType.Outside;
dataLabels.ShowLeaderLines = true;

//Save to file
workbook.SaveToFile("Chart.xlsx");
bool ShowLeaderLines { get; set; }

Property Value

bool