Back to Devexpress

How to: Create a Chart Sheet

windowsforms-119433-controls-and-libraries-spreadsheet-examples-charts-how-to-create-a-chart-sheet.md

latest1.8 KB
Original Source

How to: Create a Chart Sheet

  • Mar 17, 2023

This example demonstrates how to create a new chart sheet - a separate sheet in a workbook containing only a chart. To do this, use the ChartSheetCollection.Add method of the IWorkbook.ChartSheets collection.

To insert a chart sheet at the specified position in the ChartSheetCollection collection, call the ChartSheetCollection.Insert method.

Use the ChartSheet.Chart property to access a chart located on the chart sheet and specify or modify its settings (select chart data, change the chart type and adjust its appearance).

View Example

csharp
Worksheet worksheet = workbook.Worksheets["chartTask1"];

// Create a chart sheet containing a pie chart.
ChartSheet chartSheet = workbook.ChartSheets.Add(ChartType.Pie, worksheet["B2:C7"]);

workbook.ChartSheets.ActiveChartSheet = chartSheet;
vb
Dim worksheet As Worksheet = workbook.Worksheets("chartTask1")

' Create a chart sheet containing a pie chart.
Dim chartSheet As ChartSheet = workbook.ChartSheets.Add(ChartType.Pie, worksheet("B2:C7"))

workbook.ChartSheets.ActiveChartSheet = chartSheet

The image below shows a new chart sheet added to a workbook.