Skip to main content

PivotGridControl.RestorePivotGridFromFile(String) Method

Restores the PivotGridControl’s data and layout from the specified file.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v22.1.dll


public void RestorePivotGridFromFile(
    string path


Name Type Description
path String

A String value that specifies the path to the file which contains the pivot grid’s data and layout.


To save the pivot grid to a file, use the PivotGridControl.SavePivotGridToFile method.

To learn more, see Save and Restore Layout.


This example shows how to save (or restore) the PivotGridControl‘s data and layout to a file. To correctly restore fields if the pivot grid’s PivotGridControl.Fields collection is empty, the PivotSerializationOptions.RemoveOldFields property should be set to false.

View Example

Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.OleDb
Imports System.Windows
Imports DevExpress.Xpf.PivotGrid
Imports HowToBindToMDB.NwindDataSetTableAdapters
Imports System.IO
Imports DevExpress.Xpf.Core

Namespace HowToBindToMDB
    ''' <summary>
    ''' Interaction logic for MainWindow.xaml
    ''' </summary>
    Partial Public Class MainWindow
        Inherits Window
        Private salesPersonDataTable As New NwindDataSet.SalesPersonDataTable()
        Private salesPersonDataAdapter As New SalesPersonTableAdapter()

        Public Sub New()
            pivotGridControl1.DataSource = salesPersonDataTable
        End Sub

        Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        End Sub

        Private Sub button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            pivotGridControl1.SavePivotGridToFile("pivot.dat", True)
            pivotGridControl1.DataSource = Nothing
        End Sub

        Private Sub button2_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            If (Not File.Exists("pivot.dat")) Then
                DXMessageBox.Show("You should save the PivotGrid into a file first")
            End If
        End Sub
    End Class
End Namespace
See Also