Table of Contents

Class XlsChartLegend

Namespace
Spire.Xls.Core.Spreadsheet.Charts
Assembly
Spire.XLS.dll
public class XlsChartLegend : XlsObject, IExcelApplication, IDisposable, IChartLegend
Inheritance
XlsChartLegend
Implements
Derived
Inherited Members

Properties

AutoPosition

Automatic positioning .

public bool AutoPosition { get; }

Property Value

bool

AutoPositionX

X positioning is automatic.

public bool AutoPositionX { get; set; }

Property Value

bool

AutoPositionY

Y positioning is automatic.

public bool AutoPositionY { get; set; }

Property Value

bool

FrameFormat

public IChartFrameFormat FrameFormat { get; }

Property Value

IChartFrameFormat

HasDataTable

True if chart contains data table.

public bool HasDataTable { get; set; }

Property Value

bool

Height

Y-size. 1/4000 of chart plot. IsHMode Shall set to True

public int Height { get; set; }

Property Value

int

IncludeInLayout

Show legend without overlapping. Default is True.

public bool IncludeInLayout { get; set; }

Property Value

bool

InnerLayoutTarget

public bool InnerLayoutTarget { get; set; }

Property Value

bool

IsHMode

false value Specifies that the Height shall be interpreted as the Bottom of the chart element..

public bool IsHMode { get; set; }

Property Value

bool

IsVerticalLegend

Indicates whether if vertical legend.

public bool IsVerticalLegend { get; set; }

Property Value

bool

IsWMode

false value Specifies that the Width shall be interpreted as the Right of the chart element..

public bool IsWMode { get; set; }

Property Value

bool

IsXMode

true value Specifies that the X shall be interpreted as the Left of the chart element..

public bool IsXMode { get; set; }

Property Value

bool

IsYMode

true value Specifies that the Y shall be interpreted as the Top of the chart element..

public bool IsYMode { get; set; }

Property Value

bool

LegendEntries

Represents legend entries collection. Read only. The following code illustrates use of LegendEntries property:

//Create worksheetWorkbook workbook = new Workbook();workbook.LoadFromFile("Sample.xlsx");Worksheet worksheet = workbook.Worksheets[0];//Create chart and set rangeIChart chart = worksheet.Charts.Add();chart.DataRange = worksheet.Range["B2:C6"];//Set chart typechart.ChartType = ExcelChartType.Cone3DClustered;//Get the count of legend entriesint legendEntriesCount = chart.Legend.LegendEntries.Count;if(legendEntriesCount != 0){ //Your code here }//Save to fileworkbook.SaveToFile("Chart.xlsx");
public IChartLegendEntries LegendEntries { get; }

Property Value

IChartLegendEntries

Position

Legend position type.

public LegendPositionType Position { get; set; }

Property Value

LegendPositionType

TextArea

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

//Create worksheetWorkbook workbook = new Workbook();workbook.LoadFromFile("Sample.xlsx");Worksheet worksheet = workbook.Worksheets[0];//Create chart and set rangeIChart chart = worksheet.Charts.Add();chart.DataRange = worksheet.Range["B2:C6"];//Set chart typechart.ChartType = ExcelChartType.Cone3DClustered;//Set text area for the legendchart.Legend.TextArea.Color = Color.Gray;chart.Legend.TextArea.Size = 10;chart.Legend.TextArea.FontName = "Bernard MT Condensed";//Save to fileworkbook.SaveToFile("Chart.xlsx");
public IChartTextArea TextArea { get; }

Property Value

IChartTextArea

Width

X-size. 1/4000 of chart plot. IsWMode Shall set to True

public int Width { get; set; }

Property Value

int

X

X-position of upper-left corner. 1/4000 of chart plot. IsXMode Shall set to True

public int X { get; set; }

Property Value

int

Y

Y-position of upper-left corner. 1/4000 of chart plot. IsYMode Shall set to True

public int Y { get; set; }

Property Value

int

Methods

Clear()

Clears chart legend. The following code illustrates how to use the Clear method for legend of chart:

//Create worksheetWorkbook workbook = new Workbook();workbook.LoadFromFile("Sample.xlsx");Worksheet worksheet = workbook.Worksheets[0];//Clears the legend of chartworksheet.Charts[0].Legend.Clear();//Save to fileworkbook.SaveToFile("Chart.xlsx");
public void Clear()

Clone(object, Dictionary<int, int>, Dictionary<string, string>)

public XlsChartLegend Clone(object parent, Dictionary<int, int> dicFontIndexes, Dictionary<string, string> dicNewSheetNames)

Parameters

parent object
dicFontIndexes Dictionary<int, int>
dicNewSheetNames Dictionary<string, string>

Returns

XlsChartLegend

Delete()

Deletes chart legend. The following code illustrates how to use the Delete method for legend of chart:

//Create worksheetWorkbook workbook = new Workbook();workbook.LoadFromFile("Sample.xlsx");Worksheet worksheet = workbook.Worksheets[0];//Create chart and set rangeIChart chart = worksheet.Charts.Add();chart.DataRange = worksheet.Range["B2:C6"];//Clears the legend of chartworksheet.Charts[0].Legend.Delete();//Save to fileworkbook.SaveToFile("Chart.xlsx");
public void Delete()