Spread Silverlight Documentation > Developer's Guide > Managing Data > Importing and Exporting to XML |
You can save data and formatting to an XML file or just 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.
The following example uses the SaveXml and OpenXml methods.
CS |
Copy Code
|
---|---|
gcSpreadSheet1.Sheets[0].Cells[0, 0, 2, 2].Text = "Test"; SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Xml File (.xml)|*.xml"; bool? useClick = saveFileDialog.ShowDialog(); if (useClick == true) { var stream = saveFileDialog.OpenFile(); gcSpreadSheet1.SaveXml(stream); //gcSpreadSheet1.SaveXml(stream, true); stream.Dispose(); } //or OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Xml File (.xml)|*.xml"; bool? useClick = openFileDialog.ShowDialog(); if (useClick == true) { var stream = openFileDialog.File.OpenRead(); stream.Seek(0, System.IO.SeekOrigin.Begin); gcSpreadSheet1.OpenXml(stream); stream.Dispose(); } |
VB.NET |
Copy Code
|
---|---|
GcSpreadSheet1.Sheets(0).Cells(0, 0, 2, 2).Text = "Test" Dim saveFileDialog = New SaveFileDialog() saveFileDialog.Filter = "Xml File(.xml)|*.xml" Dim useClick As Boolean = saveFileDialog.ShowDialog() If (useClick = True) Then Dim stream = saveFileDialog.OpenFile() GcSpreadSheet1.SaveXml(stream) 'GcSpreadSheet1.SaveXml(stream, True) End If ' or Dim openFileDialog = New OpenFileDialog() openFileDialog.Filter = "Xml File(.xml)|*.xml" Dim useClick As Boolean = openFileDialog.ShowDialog() If (useClick = True) Then Dim stream = openFileDialog.File.OpenRead() stream.Seek(0, IO.SeekOrigin.Begin) GcSpreadSheet1.OpenXml(stream) End If |