GrapeCity.Xaml.SpreadSheet.Data
SaveXmlAsync(Stream,Boolean) Method
Example 


GrapeCity.Xaml.SpreadSheet.Data Namespace > Worksheet Class > SaveXmlAsync Method : SaveXmlAsync(Stream,Boolean) Method
The memory stream.
Specifies whether to only save data.
Saves the worksheet to an XML stream asynchronously.
Syntax
'Declaration
 
Public Overloads Function SaveXmlAsync( _
   ByVal xmlStream As Stream, _
   ByVal dataOnly As Boolean _
) As IAsyncAction
'Usage
 
Dim instance As Worksheet
Dim xmlStream As Stream
Dim dataOnly As Boolean
Dim value As IAsyncAction
 
value = instance.SaveXmlAsync(xmlStream, dataOnly)
public IAsyncAction SaveXmlAsync( 
   Stream xmlStream,
   bool dataOnly
)

Parameters

xmlStream
The memory stream.
dataOnly
Specifies whether to only save data.
Example
This example uses the SaveXmlAsync method.
private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var filePicker = new Windows.Storage.Pickers.FileSavePicker();
                filePicker.FileTypeChoices.Add("XML Files", new List<string>() { ".xml" });
                filePicker.SuggestedFileName = "New SpreadSheet File";
                Windows.Storage.StorageFile storageFile = await filePicker.PickSaveFileAsync();
                if (storageFile != null)
                {
                    using (var stream = await storageFile.OpenStreamForWriteAsync())
                    {
                        var fileName = storageFile.FileType.ToUpperInvariant();
                        System.Xml.XmlWriter xr = System.Xml.XmlWriter.Create(stream);
                        await gcSpreadSheet1.Sheets[0].SaveXmlAsync(xr, true);
                       //await gcSpreadSheet1.Sheets[0].SaveXmlAsync(xr);    
                    }
                }
            }
            catch (Exception ex)
            {
                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(ex.Message, "Error");
                dialog.ShowAsync();
            }           
        }
 Private Async Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
    Try
        Dim filePicker As New Windows.Storage.Pickers.FileSavePicker()
        filePicker.FileTypeChoices.Add("XML Files", New List(Of String)() From {".xml"})
        filePicker.SuggestedFileName = "New SpreadSheet File"
        Dim storageFile As Windows.Storage.StorageFile = Await filePicker.PickSaveFileAsync()
        If storageFile IsNot Nothing Then
            Using stream = Await storageFile.OpenStreamForWriteAsync()
                Dim fileName = storageFile.FileType.ToUpperInvariant()                    
                Dim xr As System.Xml.XmlWriter = System.Xml.XmlWriter.Create(stream)
               await GcSpreadSheet1.Sheets(0).SaveXmlAsync(xr, True)
               'await GcSpreadSheet1.Sheets(0).SaveXmlAsync(xr)
            End Using
        End If
    Catch ex As Exception
        Dim dialog As Windows.UI.Popups.MessageDialog = New Windows.UI.Popups.MessageDialog(ex.Message, "Error")
        dialog.ShowAsync()
    End Try
End Sub
See Also

Reference

Worksheet Class
Worksheet Members
Overload List