Interface IChartLegendEntry
Represents a legend entry in a chart legend.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.UWP.dll
Syntax
public interface IChartLegendEntry
Properties
IsDeleted
True if this entry is deleted. otherwise False.
Declaration
bool IsDeleted { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
To know more about charts refer this link.
Examples
The following code illustrates use of IsDeleted property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
sheet.Range["A1"].Text = "Student ID";
sheet.Range["B1"].Text = "Student Name";
sheet.Range["C1"].Text = "Mark(Out of 100)";
sheet.Range["A1:C1"].AutofitColumns();
sheet.Range["A2"].Number = 1;
sheet.Range["A3"].Number = 2;
sheet.Range["A4"].Number = 3;
sheet.Range["A5"].Number = 4;
sheet.Range["A6"].Number = 5;
sheet.Range["B2"].Text = "Andrew";
sheet.Range["B3"].Text = "Marson";
sheet.Range["B4"].Text = "Jack";
sheet.Range["B5"].Text = "Sam";
sheet.Range["B6"].Text = "Breto";
sheet.Range["C2"].Number = 77;
sheet.Range["C3"].Number = 45;
sheet.Range["C4"].Number = 92;
sheet.Range["C5"].Number = 39;
sheet.Range["C6"].Number = 55;
//Create a Chart
IChartShape chart = sheet.Charts.Add();
chart.LeftColumn = 5;
chart.RightColumn = 11;
chart.Name = "Student Sample Chart";
chart.ChartType = ExcelChartType.Cone_Clustered_3D;
chart.DataRange = sheet.Range["B2:C6"];
//Create a chartLegend
IChartLegend chartLegend = chart.Legend;
chartLegend.LegendEntries[0].Delete(); // Delete the first legend entry outof five entires
//True if the entry is deleted
bool isDeletedEntry = chartLegend.LegendEntries[0].IsDeleted;
if(isDeletedEntry)
{
//Your Code here
}
workbook.SaveAs("Charts.xlsx");
workbook.Close();
}
IsFormatted
True if the legend entry is formatted. otherwise False.
Declaration
bool IsFormatted { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
To know more about charts refer this link.
Examples
The following code illustrates use of IsFormatted property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
sheet.Range["A1"].Text = "Student ID";
sheet.Range["B1"].Text = "Student Name";
sheet.Range["C1"].Text = "Mark(Out of 100)";
sheet.Range["A1:C1"].AutofitColumns();
sheet.Range["A2"].Number = 1;
sheet.Range["A3"].Number = 2;
sheet.Range["A4"].Number = 3;
sheet.Range["A5"].Number = 4;
sheet.Range["A6"].Number = 5;
sheet.Range["B2"].Text = "Andrew";
sheet.Range["B3"].Text = "Marson";
sheet.Range["B4"].Text = "Jack";
sheet.Range["B5"].Text = "Sam";
sheet.Range["B6"].Text = "Breto";
sheet.Range["C2"].Number = 77;
sheet.Range["C3"].Number = 45;
sheet.Range["C4"].Number = 92;
sheet.Range["C5"].Number = 39;
sheet.Range["C6"].Number = 55;
//Create a Chart
IChartShape chart = sheet.Charts.Add();
chart.LeftColumn = 5;
chart.RightColumn = 11;
chart.Name = "Student Sample Chart";
chart.ChartType = ExcelChartType.Cone_Clustered_3D;
chart.DataRange = sheet.Range["B2:C6"];
//Create a chartLegend
IChartLegend chartLegend = chart.Legend;
chartLegend.LegendEntries[1].TextArea.Color = ExcelKnownColors.Blue_grey;
//True if the legend entry is formatted
bool isEntryFromatted = chartLegend.LegendEntries[1].IsFormatted;
if(isEntryFromatted)
{
//Your Code here
}
workbook.SaveAs("Charts.xlsx");
workbook.Close();
}
TextArea
Gets the text area of the legend entry. Read-only.
Declaration
IChartTextArea TextArea { get; }
Property Value
Type |
---|
IChartTextArea |
Remarks
To know more about charts refer this link.
Examples
The following code illustrates use of TextArea property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
sheet.Range["A1"].Text = "Student ID";
sheet.Range["B1"].Text = "Student Name";
sheet.Range["C1"].Text = "Mark(Out of 100)";
sheet.Range["A1:C1"].AutofitColumns();
sheet.Range["A2"].Number = 1;
sheet.Range["A3"].Number = 2;
sheet.Range["A4"].Number = 3;
sheet.Range["A5"].Number = 4;
sheet.Range["A6"].Number = 5;
sheet.Range["B2"].Text = "Andrew";
sheet.Range["B3"].Text = "Marson";
sheet.Range["B4"].Text = "Jack";
sheet.Range["B5"].Text = "Sam";
sheet.Range["B6"].Text = "Breto";
sheet.Range["C2"].Number = 77;
sheet.Range["C3"].Number = 45;
sheet.Range["C4"].Number = 92;
sheet.Range["C5"].Number = 39;
sheet.Range["C6"].Number = 55;
//Create a Chart
IChartShape chart = sheet.Charts.Add();
chart.LeftColumn = 5;
chart.RightColumn = 11;
chart.Name = "Student Sample Chart";
chart.ChartType = ExcelChartType.Cone_Clustered_3D;
chart.DataRange = sheet.Range["B2:C6"];
//Create a chartLegend
IChartLegend chartLegend = chart.Legend;
chartLegend.LegendEntries[1].TextArea.Color = ExcelKnownColors.Blue_grey;
chartLegend.LegendEntries[1].TextArea.Size = 10;
chartLegend.LegendEntries[1].TextArea.FontName = "Bernard MT Condensed";
workbook.SaveAs("Charts.xlsx");
workbook.Close();
}
Methods
Clear()
Clears the legend entry.
Declaration
void Clear()
Remarks
To know more about charts refer this link.
Examples
The following code illustrates how to use Clear method for legend.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
sheet.Range["A1"].Text = "Student ID";
sheet.Range["B1"].Text = "Student Name";
sheet.Range["C1"].Text = "Mark(Out of 100)";
sheet.Range["A1:C1"].AutofitColumns();
sheet.Range["A2"].Number = 1;
sheet.Range["A3"].Number = 2;
sheet.Range["A4"].Number = 3;
sheet.Range["A5"].Number = 4;
sheet.Range["A6"].Number = 5;
sheet.Range["B2"].Text = "Andrew";
sheet.Range["B3"].Text = "Marson";
sheet.Range["B4"].Text = "Jack";
sheet.Range["B5"].Text = "Sam";
sheet.Range["B6"].Text = "Breto";
sheet.Range["C2"].Number = 77;
sheet.Range["C3"].Number = 45;
sheet.Range["C4"].Number = 92;
sheet.Range["C5"].Number = 39;
sheet.Range["C6"].Number = 55;
//Create a Chart
IChartShape chart = sheet.Charts.Add();
chart.LeftColumn = 5;
chart.RightColumn = 11;
chart.Name = "Student Sample Chart";
chart.ChartType = ExcelChartType.Cone_Clustered_3D;
chart.DataRange = sheet.Range["B2:C6"];
//Create a chartLegend
IChartLegend chartLegend = chart.Legend;
chartLegend.LegendEntries[1].TextArea.Color = ExcelKnownColors.Blue_grey;
chartLegend.LegendEntries[1].TextArea.Size = 10;
chartLegend.LegendEntries[1].TextArea.FontName = "Bernard MT Condensed";
//Clear the legend entry
chartLegend.LegendEntries[1].Clear();
workbook.SaveAs("Charts.xlsx");
workbook.Close();
}
Delete()
Deletes the legend entry.
Declaration
void Delete()
Remarks
To know more about charts refer this link.
Examples
The following code illustrates how to use Delete method for legend.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
sheet.Range["A1"].Text = "Student ID";
sheet.Range["B1"].Text = "Student Name";
sheet.Range["C1"].Text = "Mark(Out of 100)";
sheet.Range["A1:C1"].AutofitColumns();
sheet.Range["A2"].Number = 1;
sheet.Range["A3"].Number = 2;
sheet.Range["A4"].Number = 3;
sheet.Range["A5"].Number = 4;
sheet.Range["A6"].Number = 5;
sheet.Range["B2"].Text = "Andrew";
sheet.Range["B3"].Text = "Marson";
sheet.Range["B4"].Text = "Jack";
sheet.Range["B5"].Text = "Sam";
sheet.Range["B6"].Text = "Breto";
sheet.Range["C2"].Number = 77;
sheet.Range["C3"].Number = 45;
sheet.Range["C4"].Number = 92;
sheet.Range["C5"].Number = 39;
sheet.Range["C6"].Number = 55;
//Create a Chart
IChartShape chart = sheet.Charts.Add();
chart.LeftColumn = 5;
chart.RightColumn = 11;
chart.Name = "Student Sample Chart";
chart.ChartType = ExcelChartType.Cone_Clustered_3D;
chart.DataRange = sheet.Range["B2:C6"];
//Create a chartLegend
IChartLegend chartLegend = chart.Legend;
// Delete the first legend entry out of five entires
chartLegend.LegendEntries[0].Delete();
workbook.SaveAs("Charts.xlsx");
workbook.Close();
}