Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
Row

ChartSheetCollection.Insert(Int32, ChartType) Method

Creates a new chart sheet of the specified type and appends it to the collection at the specified position.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v19.1.Core.dll

Declaration

ChartSheet Insert(
    int index,
    ChartType chartType
)

Parameters

Name Type Description
index Int32

A zero-based integer which specifies the position at which a new chart sheet should be inserted.

chartType ChartType

A ChartType enumeration member specifying the chart type.

Returns

Type Description
ChartSheet

A ChartSheet object that specifies the created chart sheet.

Remarks

The Insert 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.

If the index passed as a parameter to this method is less than zero, or exceeds the number of chart sheets in the collection, this method throws an exception of the ArgumentOutOfRangeException type.

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

To insert a new chart sheet at the end of the collection, use the ChartSheetCollection.Add method.

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

Example

Dim worksheet As Worksheet = workbook.Worksheets("chartTask1")

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

' Insert a new chart sheet at the specified position in the chart sheet collection.
workbook.ChartSheets.Insert(0, ChartType.ColumnClustered, worksheet("B2:C7"))

' Add a new chart sheet to the end of the collection.
Dim chartSheet As ChartSheet = workbook.ChartSheets.Insert(2, ChartType.BarClustered)
' Select chart data.
chartSheet.Chart.SelectData(worksheet("B2:C7"))

The following code snippets (auto-collected from DevExpress Examples) contain references to the Insert(Int32, ChartType) 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.

See Also