Spread WPF Documentation
Importing and Exporting to XML
Spread WPF Documentation > Developer's Guide > Managing Data > Importing and Exporting to XML

You can save data and formatting to an XML file or just the data. Data and formatting are imported when loading from an XML file.

You can use the OpenXml method to load data in code and the SaveXml method to save data.

Using Code

The following example uses the SaveXml and OpenXml methods.

CS
Copy Code
gcSpreadSheet1.Sheets[0].Cells[0, 0, 2, 2].Text = "Test";         
gcSpreadSheet1.Invalidate();   
private void button1_Click(object sender, RoutedEventArgs e)
        {
            string fileName = "c:\\zipfile\\myser.xml";
            System.IO.Stream stream = System.IO.File.Open(fileName, System.IO.FileMode.Create);
            gcSpreadSheet1.SaveXml(stream);
            gcSpreadSheet1.Invalidate();
        }
VB.NET
Copy Code
GcSpreadSheet1.Sheets(0).Cells(0, 0, 2, 2).Text = "Test"         
GcSpreadSheet1.Invalidate()  
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
        Dim fileName As String
        Dim stream As System.IO.Stream
        fileName = "c:\zipfile\myser.xml"
        stream = System.IO.File.Open(fileName, System.IO.FileMode.Create)
        GcSpreadSheet1.SaveXml(stream)
       'GcSpreadSheet1.SaveXml(stream, True)
        GcSpreadSheet1.Invalidate()
    End Sub