Spread for ASP.NET 13 Product Documentation
FarPoint.Web.Spread Assembly / FarPoint.Web.Spread Namespace / ExcelSparklineSetting Class / Serialize Method
XmlTextWriter object used to save the object
Example


In This Topic
    Serialize Method (ExcelSparklineSetting)
    In This Topic
    Saves the object to XML.
    Syntax
    'Declaration
     
    Public Function Serialize( _
       ByVal w As XmlTextWriter _
    ) As Boolean
    'Usage
     
    Dim instance As ExcelSparklineSetting
    Dim w As XmlTextWriter
    Dim value As Boolean
     
    value = instance.Serialize(w)
    public bool Serialize( 
       XmlTextWriter w
    )

    Parameters

    w
    XmlTextWriter object used to save the object

    Return Value

    true if successful; otherwise, false
    Example
    This example creates sparklines.
    FarPoint.Web.Spread.ExcelSparklineSetting eSetting = new FarPoint.Web.Spread.ExcelSparklineSetting();
    eSetting.ShowMarkers = true;
    eSetting.AxisColor = Color.Cyan;
    eSetting.DisplayEmptyCellsAs = FarPoint.Web.Spread.Chart.EmptyValueStyle.Gaps;
    eSetting.DisplayHidden = true;
    eSetting.DisplayXAxis = true;
    eSetting.FirstMarkerColor = Color.AliceBlue;
    eSetting.Formula = "Sheet1!$A$4:$E$4";
    eSetting.HighMarkerColor = Color.Honeydew;
    eSetting.LastMarkerColor = Color.Lavender;
    eSetting.LineWeight = 2;
    eSetting.LowMarkerColor = Color.LawnGreen;
    eSetting.ManualMax = 3;
    eSetting.ManualMin = 1;
    eSetting.MarkersColor = Color.Magenta;
    eSetting.MaxAxisType = FarPoint.Web.Spread.SparklineAxisMinMax.Custom;
    eSetting.MinAxisType = FarPoint.Web.Spread.SparklineAxisMinMax.Individual;
    eSetting.NegativeColor = Color.NavajoWhite;
    eSetting.RightToLeft = true;
    eSetting.SeriesColor = Color.SeaGreen;
    eSetting.ShowFirst = true;
    eSetting.ShowHigh = true;
    eSetting.ShowLast = true;
    eSetting.ShowLow = true;
    eSetting.ShowNegative = true;
    
    FarPoint.Web.Spread.ExcelSparklineSetting ess = eSetting;
    string fileName = "c:\\ExcelSparklineSetting.xml";
    
    //Serialize
    System.IO.Stream stream;
    stream = System.IO.File.Open(fileName, System.IO.FileMode.Create);
    System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8);
    writer.Formatting = System.Xml.Formatting.Indented; writer.Indentation = 2;
    writer.WriteStartDocument();
    writer.WriteStartElement("ExcelSparklineSetting");
    writer.WriteEndElement();
    writer.WriteEndDocument();
    writer.Close();
    
    //Deserialize
    FarPoint.Web.Spread.ExcelSparklineSetting ess1 = new FarPoint.Web.Spread.ExcelSparklineSetting();
    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
    doc.Load(fileName);
    System.Xml.XmlNode node;
    node = doc.FirstChild;
    while (!node.Name.Equals("ExcelSparklineSetting"))
        node = node.NextSibling;
    System.Xml.XmlNodeReader r = new System.Xml.XmlNodeReader(node);
    r.Read();
    Dim eSetting As New FarPoint.Web.Spread.ExcelSparklineSetting()
    eSetting.ShowMarkers = True
    eSetting.AxisColor = Color.Cyan
    eSetting.DisplayEmptyCellsAs = FarPoint.Web.Spread.Chart.EmptyValueStyle.Gaps
    eSetting.DisplayHidden = True
    eSetting.DisplayXAxis = True
    eSetting.FirstMarkerColor = Color.AliceBlue
    eSetting.Formula = "Sheet1!$A$4:$E$4"
    eSetting.HighMarkerColor = Color.Honeydew
    eSetting.LastMarkerColor = Color.Lavender
    eSetting.LineWeight = 2
    eSetting.LowMarkerColor = Color.LawnGreen
    eSetting.ManualMax = 3
    eSetting.ManualMin = 1
    eSetting.MarkersColor = Color.Magenta
    eSetting.MaxAxisType = FarPoint.Web.Spread.SparklineAxisMinMax.[Custom]
    eSetting.MinAxisType = FarPoint.Web.Spread.SparklineAxisMinMax.Individual
    eSetting.NegativeColor = Color.NavajoWhite
    eSetting.RightToLeft = True
    eSetting.SeriesColor = Color.SeaGreen
    eSetting.ShowFirst = True
    eSetting.ShowHigh = True
    eSetting.ShowLast = True
    eSetting.ShowLow = True
    eSetting.ShowNegative = True
    
    Dim ess As FarPoint.Web.Spread.ExcelSparklineSetting = eSetting
    Dim fileName As String = "c:\ExcelSparklineSetting.xml"
    
    'Serialize
    Dim stream As System.IO.Stream
    stream = System.IO.File.Open(fileName, System.IO.FileMode.Create)
    Dim writer As New System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8)
    writer.Formatting = System.Xml.Formatting.Indented
    writer.Indentation = 2
    writer.WriteStartDocument()
    writer.WriteStartElement("ExcelSparklineSetting")
    writer.WriteEndElement()
    writer.WriteEndDocument()
    writer.Close()
    
    'Deserialize
    Dim ess1 As New FarPoint.Web.Spread.ExcelSparklineSetting()
    Dim doc As New System.Xml.XmlDocument()
    doc.Load(fileName)
    Dim node As System.Xml.XmlNode
    node = doc.FirstChild
    While Not node.Name.Equals("ExcelSparklineSetting")
        node = node.NextSibling
    End While
    Dim r As New System.Xml.XmlNodeReader(node)
    r.Read()
    See Also