Back to Devexpress

How to: Remove a Chart Sheet

officefileapi-120718-spreadsheet-document-api-examples-charts-how-to-remove-a-chart-sheet.md

latest1.2 KB
Original Source

How to: Remove a Chart Sheet

  • Sep 19, 2023

To delete a chart sheet from a workbook, remove it from the workbook’s ChartSheetCollection by using the ChartSheetCollection.Remove or ChartSheetCollection.RemoveAt method.

You can also move a chart back to the worksheet containing the source data by using the chart’s ChartObject.MoveToWorksheet method.

csharp
// Create the first chart sheet.
workbook.ChartSheets.Add();

// Create the second chart sheet.
workbook.ChartSheets.Add(ChartType.Pie, worksheet["B2:C7"]);

// Remove the first chart sheet.
workbook.ChartSheets.RemoveAt(0);
vb
' Create the first chart sheet.
workbook.ChartSheets.Add()

' Create the second chart sheet.
workbook.ChartSheets.Add(ChartType.Pie, worksheet("B2:C7"))

' Remove the first chart sheet.
workbook.ChartSheets.RemoveAt(0)