All docs
V20.1
20.2 (EAP/Beta)
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Row

PivotTable.MoveTo(CellRange) Method

Moves a pivot table to the specified location.

Namespace: DevExpress.Spreadsheet

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

Declaration

PivotTable MoveTo(
    CellRange location
)
Function MoveTo(
    location As CellRange
) As PivotTable

Parameters

Name Type Description
location CellRange

A CellRange object that specifies a cell or cell range in the upper-left corner of the PivotTable report's destination range.

Returns

Type Description
PivotTable

A PivotTable object that represents the moved pivot table.

Remarks

The MoveTo method returns one of the following values depending on the report target location:

  • A reference to the current PivotTable object if the pivot table is moved to a new location in the same worksheet.
  • A reference to a new PivotTable object if the pivot table is moved to another worksheet. This operation removes the pivot table from the collection of pivot tables in the source worksheet and appends it to the PivotTableCollection collection of the target worksheet. Correspondingly, a reference to the PivotTable object in the source worksheet becomes invalid. If you try to use it in your application, a System.InvalidOperationException will be thrown.

The example below demonstrates how to move a pivot table to another worksheet in a workbook.

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

' Create a new worksheet.
Dim targetWorksheet As Worksheet = workbook.Worksheets.Add()

' Access the pivot table by its name in the collection
' and move it to the new worksheet.
worksheet.PivotTables("PivotTable1").MoveTo(targetWorksheet("B2"))
' Refresh the pivot table.
targetWorksheet.PivotTables("PivotTable1").Cache.Refresh()

workbook.Worksheets.ActiveWorksheet = targetWorksheet
See Also