[]
        
(Showing Draft Content)

C1.Win.C1FlexGrid.C1FlexGridBase.WriteXml

WriteXml Method

WriteXml(string, XmlOptions)

Saves the grid contents to an Xml document.

Declaration
public void WriteXml(string fileName, XmlOptions options = XmlOptions.All)
Parameters
Type Name Description
string fileName

Name of the file to save, including the path.

XmlOptions options

Options that allows to choose which elements of FlexGrid should be saved

Remarks

The grid serializes all its contents into the Xml document, including the data stored in the cells, row and column properties, styles, images, etc.

Objects of custom types stored in the grid are also serialized as long as they have an associated TypeConverter that provides conversions to and from string.

The WriteXml(string, XmlOptions) method has several overloads that allow you to save several grids into a single Xml document, along with other information stored in the Xml document.

Examples

The code below saves a grid into an Xml file:

// save a grid into am Xml file
flex.WriteXml(fileName);

The code below saves two grids into an Xml file, then reads them back in reverse order:

// prepare XmlTextWriter
XmlTextWriter w = new XmlTextWriter(fileName, new UTF8Encoding(false));
w.Formatting = Formatting.Indented;
w.WriteStartDocument();
w.WriteStartElement("Grids");

// save first grid
w.WriteStartElement(c1FlexGrid1.Name);
c1FlexGrid1.WriteXml(w);
w.WriteEndElement();

// save second grid
w.WriteStartElement(c1FlexGrid2.Name);
c1FlexGrid2.WriteXml(w);
w.WriteEndElement();

// close document
w.WriteEndElement();
w.Close();

// load document from file
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
XmlNode n = doc.SelectSingleNode("Grids");

// load grids in reverse order
c1FlexGrid2.ReadXml(n.ChildNodes[0]);
c1FlexGrid1.ReadXml(n.ChildNodes[1]);

WriteXml(TextWriter, XmlOptions)

Saves the grid contents to an Xml document.

Declaration
public void WriteXml(TextWriter tw, XmlOptions options = XmlOptions.All)
Parameters
Type Name Description
TextWriter tw

The TextWriter where the document is saved.

XmlOptions options

Options that allows to choose which elements of FlexGrid should be saved

WriteXml(Stream, XmlOptions)

Saves the grid contents to an Xml document.

Declaration
public void WriteXml(Stream stream, XmlOptions options = XmlOptions.All)
Parameters
Type Name Description
Stream stream

The Stream where the document is saved.

XmlOptions options

Options that allows to choose which elements of FlexGrid should be saved

WriteXml(XmlTextWriter)

Saves the grid contents to an Xml document.

Declaration
public virtual void WriteXml(XmlTextWriter w)
Parameters
Type Name Description
XmlTextWriter w

The System.Xml.XmlTextWriter where the document is saved.

WriteXml(XmlTextWriter, XmlOptions)

Saves the grid contents to an Xml document.

Declaration
public virtual void WriteXml(XmlTextWriter w, XmlOptions options)
Parameters
Type Name Description
XmlTextWriter w

The System.Xml.XmlTextWriter where the document is saved.

XmlOptions options

Options that allows to choose which elements of FlexGrid should be saved