Table of Contents

Interface IChartLegendEntry

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

Represents a legend entry in a chart legend.

public interface IChartLegendEntry

Properties

BackgroundMode

Display mode of the background.

ChartBackgroundMode BackgroundMode { get; set; }

Property Value

ChartBackgroundMode

IsDeleted

If true then this entry deleted. otherwise false. The following code illustrates use of IsDeleted property:

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

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["B2:C6"];

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

//Create a chartLegend
IChartLegend chartLegend = chart.Legend;
chartLegend.LegendEntries[0].Delete();

//True if the entry is deleted
bool isDeletedEntry = chartLegend.LegendEntries[0].IsDeleted;
if(isDeletedEntry){ //Your code here }

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

Property Value

bool

IsFormatted

True if the legend entry has been formatted. The following code illustrates use of IsFormatted property:

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

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["B2:C6"];

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

//Create a chartLegend
IChartLegend chartLegend = chart.Legend;
chartLegend.LegendEntries[1].TextArea.Color = Color.Blue;

//True if the legend entry is formatted
bool isEntryFromatted = chartLegend.LegendEntries[1].IsFormatted;
if(isEntryFromatted){ //Your code here }

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

Property Value

bool

TextArea

Represents text area. The following code illustrates use of TextArea property:

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

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["B2:C6"];

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

//Create a chartLegend
IChartLegend chartLegend = chart.Legend;
chartLegend.LegendEntries[1].TextArea.Color = Color.Blue;
chartLegend.LegendEntries[1].TextArea.Size = 10;
chartLegend.LegendEntries[1].TextArea.FontName = "Bernard MT Condensed";

//Save to file
workbook.SaveToFile("Chart.xlsx");
IChartTextArea TextArea { get; }

Property Value

IChartTextArea

Methods

Delete()

Deletes current legend entry. The following code illustrates how to use Delete method for legend:

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

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["B2:C6"];

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

//Create a chartLegend
IChartLegend chartLegend = chart.Legend;

//Delete the first legend entry out of five entires
chartLegend.LegendEntries[0].Delete();

//Save to file
workbook.SaveToFile("Chart.xlsx");
void Delete()