officefileapi-devexpress-dot-spreadsheet-dot-pivottable-dot-moveto-x28-devexpress-dot-spreadsheet-dot-cellrange-x29.md
Moves a pivot table to the specified location.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
PivotTable MoveTo(
CellRange location
)
Function MoveTo(
location As CellRange
) As PivotTable
| 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.
|
| Type | Description |
|---|---|
| PivotTable |
A PivotTable object that represents the moved pivot table.
|
The MoveTo method returns one of the following values depending on the report target location:
The example below demonstrates how to move a pivot table to another worksheet in a workbook.
Worksheet worksheet = workbook.Worksheets["Report1"];
// Create a new worksheet.
Worksheet targetWorksheet = 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;
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
The following code snippets (auto-collected from DevExpress Examples) contain references to the MoveTo(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.
// Change the pivot table location.
worksheet.PivotTables["PivotTable1"].MoveTo(worksheet["A7"]);
// Refresh the pivot table.
// Change the pivot table location.
worksheet.PivotTables["PivotTable1"].MoveTo(worksheet["A7"]);
// Refresh the pivot table.
// Change the pivot table location.
worksheet.PivotTables["PivotTable1"].MoveTo(worksheet["A7"]);
// Refresh the pivot table.
' Change the pivot table location.
worksheet.PivotTables("PivotTable1").MoveTo(worksheet("A7"))
' Refresh the pivot table.
' Change the pivot table location.
worksheet.PivotTables("PivotTable1").MoveTo(worksheet("A7"))
' Refresh the pivot table.
' Change the pivot table location.
worksheet.PivotTables("PivotTable1").MoveTo(worksheet("A7"))
' Refresh the pivot table.
See Also