Back to Devexpress

ChartSheetCollection.Add(ChartType, CellRange) Method

officefileapi-devexpress-dot-spreadsheet-dot-chartsheetcollection-dot-add-x28-devexpress-dot-spreadsheet-dot-charts-dot-charttype-devexpress-dot-spreadsheet-dot-cellrange-x29.md

latest5.9 KB
Original Source

ChartSheetCollection.Add(ChartType, CellRange) Method

Creates a new chart sheet with the specified chart and appends it to the end of the collection.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
ChartSheet Add(
    ChartType chartType,
    CellRange range
)
vb
Function Add(
    chartType As ChartType,
    range As CellRange
) As ChartSheet

Parameters

NameTypeDescription
chartTypeChartType

A ChartType enumeration member specifying the chart type.

| | range | CellRange |

A CellRange containing chart data.

|

Returns

TypeDescription
ChartSheet

A ChartSheet object that specifies the new chart sheet.

|

Remarks

The Add method creates a new chart sheet under the default name like ChartN, where N is a number that is greater by 1 than the maximum number used in chart sheet names of the same type. To change the chart sheet name, use the ChartSheet.Name property. Use the ChartSheet.Chart property to access a chart located on the chart sheet and fine-tune its settings and adjust the chart appearance.

To insert a new chart sheet to the specified position in the collection, use the ChartSheetCollection.Insert method.

To remove a chart sheet from the collection, use the ChartSheetCollection.Remove or ChartSheetCollection.RemoveAt method.

Example

View Example

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
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;

The following code snippets (auto-collected from DevExpress Examples) contain references to the Add(ChartType, CellRange) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/CodeExamples/ChartSheetActions.cs#L14

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

winforms-spreadsheet-chart-api/CS/SpreadsheetChartAPISamples/CodeExamples/ChartSheetActions.cs#L14

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

wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/CodeExamples/ChartSheetActions.vb#L15

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

winforms-spreadsheet-chart-api/VB/SpreadsheetChartAPISamples/CodeExamples/ChartSheetActions.vb#L14

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

See Also

Chart

ChartSheetCollection Interface

ChartSheetCollection Members

DevExpress.Spreadsheet Namespace