Spread Windows Forms 12.0 Product Documentation
Saving or Loading a Chart
Spread Windows Forms 12.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.

Using Code

Use general methods to save to a file.

Example

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() 

Using Code

Use general methods to read from a file.

Example

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() 

Using the Designer

  1. Select the arrow icon at the top right edge of the control after drawing the control on the form to see the menu options.
  2. Choose Save to XML or Load from XML.