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


GrapeCity.Xaml.SpreadSheet.UI Namespace > GcSpreadSheet Class > SaveXmlAsync Method : SaveXmlAsync(Stream,Boolean) Method
The XML stream.
Whether to save data only.
Saves the data on the sheet to the specified XML stream asynchronously.
Syntax
'Declaration
 
Public Overloads Function SaveXmlAsync( _
   ByVal xmlStream As Stream, _
   ByVal dataOnly As Boolean _
) As IAsyncAction
'Usage
 
Dim instance As GcSpreadSheet
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 XML stream.
dataOnly
Whether to save data only.
Example
This example uses the SaveXmlAsync method.
private void Grid_Loaded_1(object sender, RoutedEventArgs e)
        {
            gcSpreadSheet1.Sheets[0].Cells[0, 0, 2, 2].Text = "Test";
        }

        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();
                        await gcSpreadSheet1.SaveXmlAsync(stream);
                        //await gcSpreadSheet1.SaveXmlAsync(stream, true);
                    }
                }
            }
            catch (Exception ex)
            {
                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(ex.Message, "Error");
                dialog.ShowAsync();
            }           
        }

        private async void Button_Click_2(object sender, RoutedEventArgs e)
        {
            try
            {
                var filePicker = new Windows.Storage.Pickers.FileOpenPicker();
                filePicker.FileTypeFilter.Add(".xml");                
                Windows.Storage.StorageFile storageFile = await filePicker.PickSingleFileAsync();
                if (storageFile != null)
                {
                    using (var stream = await storageFile.OpenStreamForReadAsync())
                    {
                       await gcSpreadSheet1.OpenXmlAsync(stream);
                    }
                }
            }
            catch (Exception ex)
            {
                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(ex.Message, "Error");
                dialog.ShowAsync();
            }
        }     
    }
Private Sub MainPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
        gcSpreadSheet1.Sheets(0).Cells(0, 0, 2, 2).Text = "Test"
    End Sub

    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()                    
                    await gcSpreadSheet1.SaveXmlAsync(stream)
                    'await gcSpreadSheet1.SaveXmlAsync(stream, True)
                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
    
    Private Async Sub Button_Click_2(sender As Object, e As RoutedEventArgs)
        Try
            Dim filePicker As New Windows.Storage.Pickers.FileOpenPicker()
            filePicker.FileTypeFilter.Add(".xml")
            Dim storageFile As Windows.Storage.StorageFile = Await filePicker.PickSingleFileAsync()

            If storageFile IsNot Nothing Then
                Using stream = Await storageFile.OpenStreamForReadAsync()
                    await gcSpreadSheet1.OpenXmlAsync(stream)
                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

GcSpreadSheet Class
GcSpreadSheet Members
Overload List