# Save/Load Chart Control

Learn how to save and load Chart controls from an XML file with ease using Spread.NET.

## Content

Chart controls can be saved to and loaded from an XML file. This feature is also available from the smart tag of the FpChart control placed on the form.

## Using Code

You can load the XML file with the [LoadFromTemplate](/spreadnet/api/latest/online-win/FarPoint.Win.Chart/FarPoint.Win.Chart.FpChart.LoadFromTemplate.html) method of the [FpChart](/spreadnet/api/latest/online-win/FarPoint.Win.Chart/FarPoint.Win.Chart.FpChart.html) class and save it to the XML file with the [SaveToTemplate](/spreadnet/api/latest/online-win/FarPoint.Win.Chart/FarPoint.Win.Chart.FpChart.SaveToTemplate.html) method.

## Example

The following sample code saves or loads the chart control into an XML file.

```csharp
string f;
f = "c:\\temp\\chart.xml";
System.IO.FileStream s = new System.IO.FileStream(f, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite);
fpChart1.SaveToTemplate(s);
//fpChart1.LoadFromTemplate(s);
```

```vbnet
Dim f As String
f = "c:\chart.xml"
Dim s As New System.IO.FileStream(f, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite)
FpChart1.SaveToTemplate(s)
'FpChart1.LoadFromTemplate(s)
```