Spread Windows Forms 8.0 Product Documentation > Developer's Guide > Working with the Chart Control > Creating Charts > Saving or Loading a Chart |
You can read or write to a file or stream using the IXmlSerializable interface.
You can also save and load xml files at design time. Select the arrow icon at the top right edge of the control after drawing the control on the form to see the menu options.
Use general methods to save to a file.
The following code writes to a file.
C# |
Copy Code
|
---|---|
ChartModel model = fpChart1.Model; XmlTextWriter writer = new XmlTextWriter("c:\\home\\temp\\test.xml", null); model.WriteXml(writer); writer.Close(); |
VB |
Copy Code
|
---|---|
Dim model As ChartModel = fpChart1.Model Dim writer As New XmlTextWriter("c:\home\temp\test.xml", Nothing) model.WriteXml(writer) writer.Close() |
Use general methods to read from a file.
The following code reads from a file.
C# |
Copy Code
|
---|---|
ChartModel model = fpChart1.Model; XmlTextReader reader = new XmlTextReader("c:\\home\\temp\\test.xml"); model.ReadXml(reader); reader.Close(); |
VB |
Copy Code
|
---|---|
Dim model As ChartModel = fpChart1.Model Dim reader As New XmlTextReader("c:\home\temp\test.xml") model.ReadXml(reader) reader.Close() |