Skip to main content

PivotGridControl.SavePivotGridToFile(String) Method

Saves the Pivot Grid Control’s data and full layout to the specified file.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v24.1.dll

NuGet Package: DevExpress.Win.PivotGrid

Declaration

public void SavePivotGridToFile(
    string path
)

Parameters

Name Type Description
path String

A string that specifies the path to the file in which the control’s data and layout will be saved.

Remarks

This method saves the original data that is provided by a data store to the specified file. The data can be loaded later in the same or another grid control by creating a PivotFileDataSource object, and assigning it to the PivotGridControl.DataSource property. No connection to the original data store is required.

The SavePivotGridToFile method also saves the full layout along with the data to the file. When the data is restored, the layout is restored as well, regardless of the layout settings specified by the PivotGridControl.OptionsLayout property.

Note

Saving PivotGrid’s data to a file or stream is not supported for Server Mode and OLAP data sources.

Example

The following example shows how to save the Pivot Grid Control’s data to a file, and then load it later.

To save the data the PivotGridControl.SavePivotGridToFile method is called. To restore the data, a PivotFileDataSource object is initialized and assigned to the PivotGridControl.DataSource property.

using DevExpress.Data.PivotGrid;

string filePath = "c:\\pivotData.dat";
// Save the control's data to the file.
pivotGridControl1.SavePivotGridToFile(filePath);

//...

// Restore the saved data
PivotFileDataSource ds = new PivotFileDataSource(filePath);
pivotGridControl1.DataSource = ds;
See Also