Documents for Excel .NET Edition | GCDocuments
Features / Chart / Create and Delete Chart
In This Topic
    Create and Delete Chart
    In This Topic

    GcExcel .NET allows users to create and delete chart in spreadsheets as per their requirements.

    You can create and delete chart using the properties and methods of the IShapes Interface and the IChart interface

    Create Chart

    You can create chart in a worksheet by using the AddChart method of the IShapes interface.

    Refer to the following example code to create a chart.

    C#
    Copy Code
       //Add Chart 
    IShape shape = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 200, 100, 300, 300);
    worksheet.Range["A1:D6"].Value = new object[,]
     {
           {null, "Revenue", "Profit", "Sales"},
           {"North", 10, 25, 25},
           {"East", 51, 36, 27},
           {"South", 52, 85, 30},
           {"West", 22, 65, 65}
     };
     shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], RowCol.Columns, true, true);

    Delete Chart

    You can delete an existing chart by using Delete method of the IChart interface.

    Refer to the following example code to delete a chart from your spreadsheet.

    C#
    Copy Code
    // Delete Chart
    shape.Chart.Delete();