# Loading and Saving Chart to a File

## Content



In C1Chart, each chart can be loaded from and saved to an external XML file using the Save Chart/Load Chart commands from C1Chart’s context menu at design-time or programmatically using any of the following methods:

*   LoadChartFromFile
*   SaveChartToFile
*   LoadChartAndImagesFromFile
*   SaveChartAndImagesToFile

The SaveChartAndImagesToFile and LoadChartAndImagesFromFile methods does the same as the SaveChartToFile and LoadChartFromFile methods except that they capture the various background images of the chart elements (chart, header, footer, labels).

If you only want to save the chart’s data you can do so using the SaveDataToFile and LoadDataFromFile methods of the ChartData object.

To save just the chart's data to XML, call the SaveDataToFile method, which takes the file's path as a parameter:

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in Visual Basic

DOC-SUMMARY-TAG-CLOSE

```vbnet
C1Chart1.ChartGroups.Group0.ChartData_
 .SaveDataToFile("C:\ComponentOneDocs\chartdata1.xml")
```

DOC-DETAILS-TAG-CLOSE

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in C#

DOC-SUMMARY-TAG-CLOSE

```csharp
c1Chart1.ChartGroups.Group0.ChartData
 .SaveDataToFile("C:\\ComponentOneDocs\\chartdata1.xml");
```

DOC-DETAILS-TAG-CLOSE

To load the chart's data back from XML, call the LoadDataFromFile method, which takes the file's path as a parameter:

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in Visual Basic

DOC-SUMMARY-TAG-CLOSE

```vbnet
C1Chart1.ChartGroups.Group0.ChartData_
 .LoadDataFromFile("C:\ComponentOneDocs\chartdata1.xml")
```

DOC-DETAILS-TAG-CLOSE

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in C#

DOC-SUMMARY-TAG-CLOSE

```csharp
C1Chart1.ChartGroups.Group0.ChartData_
 .LoadDataFromFile("C:\ComponentOneDocs\chartdata1.xml")
```

DOC-DETAILS-TAG-CLOSE

An in-depth discussion of the structure of the XML file is not covered here, but the file can be opened as a text file and easily dissected.

## See Also

[Saving Chart Images](/componentone/docs/win/online-chart2d/loadingandsavingchar/savingchartimages)