alexa
menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Interface IChartSeries

    Represents the collection of chart series.

    Inherited Members
    ICollection<IChartSerie>.Add(IChartSerie)
    ICollection<IChartSerie>.Clear()
    ICollection<IChartSerie>.Contains(IChartSerie)
    ICollection<IChartSerie>.CopyTo(IChartSerie[], int)
    ICollection<IChartSerie>.IsReadOnly
    ICollection<IChartSerie>.Remove(IChartSerie)
    IEnumerable<IChartSerie>.GetEnumerator()
    IParentApplication.Application
    IParentApplication.Parent
    Namespace: Syncfusion.XlsIO
    Assembly: Syncfusion.XlsIO.NET.dll
    Syntax
    public interface IChartSeries : IParentApplication, ICollection<IChartSerie>, IEnumerable<IChartSerie>, IEnumerable

    Properties

    Count

    Returns the number of IChartSerie in the IChartSeries collection. Read-only Long.

    Declaration
    int Count { get; }
    Property Value
    Type
    int
    Examples

    The following code illustrates how to get the number of IChartSerie in the IChartSeries collection.

            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                //Create worksheet
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Excel2013;
                IWorkbook workbook = application.Workbooks.Create(1);
                IWorksheet sheet = workbook.Worksheets[0];
    
                //Add data
                sheet.Range["A1"].Text = "Jan";
                sheet.Range["B1"].Text = "Feb";
                sheet.Range["C1"].Text = "Mar";
                sheet.Range["A2"].Value = "10";
                sheet.Range["B2"].Value = "20";
                sheet.Range["C2"].Value = "30";
    
                //Create chart
                IChart chart = sheet.Charts.Add();
    
                //Set range
                chart.DataRange = sheet.Range["A1:C2"];
    
                //Check count
                Console.Write(chart.Series.Count);
    
                //Save and Dispose
                workbook.SaveAs("Chart.xlsx");
                workbook.Close();
                Console.ReadKey();
            }
    //Output will be
    //1

    this[int]

    Returns a single IChartSerie object from IChartSeries collection.

    Declaration
    IChartSerie this[int index] { get; }
    Parameters
    Type Name Description
    int index
    Property Value
    Type
    IChartSerie
    Examples

    The following code illustrates how access a IChartSerie in the IChartSeries collection.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet sheet = workbook.Worksheets[0];
    
        //Add data
        sheet.Range["A1"].Text = "Jan";
        sheet.Range["B1"].Text = "Feb";
        sheet.Range["C1"].Text = "Mar";
        sheet.Range["A2"].Value = "10";
        sheet.Range["B2"].Value = "20";
        sheet.Range["C2"].Value = "30";
    
        //Create chart
        IChart chart = sheet.Charts.Add();
    
        //Set range
        chart.DataRange = sheet.Range["A1:C2"];
    
        //Set chart type
        chart.ChartType = ExcelChartType.WaterFall;
    
        //Set serie format
        IChartSerieDataFormat format = chart.Series[0].SerieFormat;
    
        //Set visibility
        format.ShowConnectorLines = false;
    
        //Save and Dispose
        workbook.SaveAs("Chart.xlsx");
        workbook.Close();
    }

    this[string]

    Returns a single IChartSerie object from IChartSeries collection.

    Declaration
    IChartSerie this[string name] { get; }
    Parameters
    Type Name Description
    string name
    Property Value
    Type
    IChartSerie
    Examples

    The following code illustrates how access a IChartSerie in the IChartSeries collection.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet sheet = workbook.Worksheets[0];
    
        //Add data
        sheet.Range["A1"].Text = "Jan";
        sheet.Range["B1"].Text = "Feb";
        sheet.Range["C1"].Text = "Mar";
        sheet.Range["A2"].Value = "10";
        sheet.Range["B2"].Value = "20";
        sheet.Range["C2"].Value = "30";
    
        //Create chart
        IChart chart = sheet.Charts.Add();
    
        //Set serie
        IChartSerie serie = chart.Series.Add("BarSerie", ExcelChartType.Bar_Clustered);
    
        //Set category labels and values
        chart.Series["BarSerie"].CategoryLabels = sheet.Range["A1:C1"];
        chart.Series["BarSerie"].Values = sheet.Range["A2:C2"];
    
        //Save and Dispose
        workbook.SaveAs("Chart.xlsx");
        workbook.Close();
    }

    Methods

    Add()

    Adds a new IChartSerie to IChartSeries collection and Returns it.

    Declaration
    IChartSerie Add()
    Returns
    Type Description
    IChartSerie

    Newly created IChartSerie object.

    Examples

    The following code illustrates how a IChartSerie can be created and added to IChartSeries collection.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet sheet = workbook.Worksheets[0];
    
        //Add data
        sheet.Range["A1"].Text = "Jan";
        sheet.Range["B1"].Text = "Feb";
        sheet.Range["C1"].Text = "Mar";
        sheet.Range["A2"].Value = "10";
        sheet.Range["B2"].Value = "20";
        sheet.Range["C2"].Value = "30";
    
        //Create chart
        IChart chart = sheet.Charts.Add();
    
        //Set serie
        IChartSerie serie = chart.Series.Add();
    
        //Set category labels and values
        serie.CategoryLabels = sheet.Range["A1:C1"];
        serie.Values = sheet.Range["A2:C2"];
    
        //Save and Dispose
        workbook.SaveAs("Chart.xlsx");
        workbook.Close();
    }

    Add(ExcelChartType)

    Adds a new IChartSerie to IChartSeries collection and Returns it.

    Declaration
    IChartSerie Add(ExcelChartType serieType)
    Parameters
    Type Name Description
    ExcelChartType serieType

    Type of new IChartSerie.

    Returns
    Type Description
    IChartSerie

    Newly created IChartSerie object.

    Examples

    The following code illustrates how a IChartSerie can be created and added to IChartSeries collection by passing ExcelChartType as a parameter.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet sheet = workbook.Worksheets[0];
    
        //Add data
        sheet.Range["A1"].Text = "Jan";
        sheet.Range["B1"].Text = "Feb";
        sheet.Range["C1"].Text = "Mar";
        sheet.Range["A2"].Value = "10";
        sheet.Range["B2"].Value = "20";
        sheet.Range["C2"].Value = "30";
    
        //Create chart
        IChart chart = sheet.Charts.Add();
    
        //Set serie
        IChartSerie serie = chart.Series.Add(ExcelChartType.Bar_Clustered);
    
        //Set category labels and values
        serie.CategoryLabels = sheet.Range["A1:C1"];
        serie.Values = sheet.Range["A2:C2"];
    
        //Save and Dispose
        workbook.SaveAs("Chart.xlsx");
        workbook.Close();
    }

    Add(string)

    Adds a new IChartSerie to IChartSeries collection and Returns it.

    Declaration
    IChartSerie Add(string name)
    Parameters
    Type Name Description
    string name

    Name of the new IChartSerie.

    Returns
    Type Description
    IChartSerie

    Newly created IChartSerie object.

    Examples

    The following code illustrates how a IChartSerie can be created and added to IChartSeries collection by passing string type as a parameter.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet sheet = workbook.Worksheets[0];
    
        //Add data
        sheet.Range["A1"].Text = "Jan";
        sheet.Range["B1"].Text = "Feb";
        sheet.Range["C1"].Text = "Mar";
        sheet.Range["A2"].Value = "10";
        sheet.Range["B2"].Value = "20";
        sheet.Range["C2"].Value = "30";
    
        //Create chart
        IChart chart = sheet.Charts.Add();
    
        //Set serie
        IChartSerie serie = chart.Series.Add("BarSerie");
    
        //Set category labels and values
        serie.CategoryLabels = sheet.Range["A1:C1"];
        serie.Values = sheet.Range["A2:C2"];
    
        //Save and Dispose
        workbook.SaveAs("Chart.xlsx");
        workbook.Close();
    }

    Add(string, ExcelChartType)

    Adds a new IChartSerie to IChartSeries collection and Returns it.

    Declaration
    IChartSerie Add(string name, ExcelChartType type)
    Parameters
    Type Name Description
    string name

    Name of the new IChartSerie.

    ExcelChartType type

    Type of new IChartSerie.

    Returns
    Type Description
    IChartSerie

    Newly created IChartSerie.

    Examples

    The following code illustrates how a IChartSerie can be created and added to IChartSeries collection by passing ExcelChartType and string type as parameters.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet sheet = workbook.Worksheets[0];
    
        //Add data
        sheet.Range["A1"].Text = "Jan";
        sheet.Range["B1"].Text = "Feb";
        sheet.Range["C1"].Text = "Mar";
        sheet.Range["A2"].Value = "10";
        sheet.Range["B2"].Value = "20";
        sheet.Range["C2"].Value = "30";
    
        //Create chart
        IChart chart = sheet.Charts.Add();
    
        //Set serie
        IChartSerie serie = chart.Series.Add("BarSerie", ExcelChartType.Bar_Clustered);
    
        //Set category labels and values
        chart.Series["BarSerie"].CategoryLabels = sheet.Range["A1:C1"];
        chart.Series["BarSerie"].Values = sheet.Range["A2:C2"];
    
        //Save and Dispose
        workbook.SaveAs("Chart.xlsx");
        workbook.Close();
    }

    Remove(string)

    Removes a IChartSerie from IChartSeries collection.

    Declaration
    void Remove(string serieName)
    Parameters
    Type Name Description
    string serieName

    IChartSerie name to remove.

    Examples

    The following code illustrates how to remove a IChartSerie from IChartSeries collection by specfiying it's name.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet sheet = workbook.Worksheets[0];
    
        //Add data
        sheet.Range["A1"].Text = "Jan";
        sheet.Range["B1"].Text = "Feb";
        sheet.Range["C1"].Text = "Mar";
        sheet.Range["A2"].Value = "10";
        sheet.Range["B2"].Value = "20";
        sheet.Range["C2"].Value = "30";
    
        //Create chart
        IChart chart = sheet.Charts.Add();
    
        //Set serie
        IChartSerie serie = chart.Series.Add("BarSerie");
    
        //Set category labels and values
        serie.CategoryLabels = sheet.Range["A1:C1"];
        serie.Values = sheet.Range["A2:C2"];
    
        //Remove Serie
        chart.Series.Remove("BarSerie");
    
        //Save and Dispose
        workbook.SaveAs("Chart.xlsx");
        workbook.Close();
    }

    RemoveAt(int)

    Removes a IChartSerie from IChartSeries collection.

    Declaration
    void RemoveAt(int index)
    Parameters
    Type Name Description
    int index

    Index of the IChartSerie to remove.

    Examples

    The following code illustrates how to remove a IChartSerie from IChartSeries collection by specfiying it's index.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet sheet = workbook.Worksheets[0];
    
        //Add data
        sheet.Range["A1"].Text = "Jan";
        sheet.Range["B1"].Text = "Feb";
        sheet.Range["C1"].Text = "Mar";
        sheet.Range["A2"].Value = "10";
        sheet.Range["B2"].Value = "20";
        sheet.Range["C2"].Value = "30";
    
        //Create chart
        IChart chart = sheet.Charts.Add();
    
        //Set serie
        IChartSerie serie = chart.Series.Add("BarSerie");
    
        //Set category labels and values
        serie.CategoryLabels = sheet.Range["A1:C1"];
        serie.Values = sheet.Range["A2:C2"];
    
        //Remove Serie
        chart.Series.RemoveAt(0);
    
        //Save and Dispose
        workbook.SaveAs("Chart.xlsx");
        workbook.Close();
    }

    Extension Methods

    CalcEngineHelper.ToArray<T>(IEnumerable<T>)
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved