windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridcontrol-dot-savepivotgridtofile-x28-system-dot-string-x29.md
Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.
Saves the Pivot Grid Control’s data and full layout to the specified file.
Namespace : DevExpress.XtraPivotGrid
Assembly : DevExpress.XtraPivotGrid.v25.2.dll
NuGet Package : DevExpress.Win.PivotGrid
public void SavePivotGridToFile(
string path
)
Public Sub SavePivotGridToFile(
path As String
)
| 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.
|
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.
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;
Imports DevExpress.Data.PivotGrid
Dim filePath As String = "c:\\pivotData.dat"
' Save the control's data to the file.
pivotGridControl1.SavePivotGridToFile(filePath)
'...
' Restore the saved data
Dim ds As PivotFileDataSource = New PivotFileDataSource(filePath)
pivotGridControl1.DataSource = ds
See Also