GrapeCity.Xaml.SpreadSheet.Data
SaveCsvAsync(Int32,Int32,Int32,Int32,Stream,TextFileSaveFlags,Encoding) Method
Example 


The starting row index.
The starting column index.
The number of rows.
The number of columns.
The stream to which to save the content.
The export flags.
The encoding.
Saves the CSV (comma-separated values) file asynchronously.
Syntax
'Declaration
 
Public Overloads Function SaveCsvAsync( _
   ByVal row As Integer, _
   ByVal column As Integer, _
   ByVal rowCount As Integer, _
   ByVal columnCount As Integer, _
   ByVal stream As Stream, _
   ByVal flags As TextFileSaveFlags, _
   ByVal encoding As Encoding _
) As IAsyncAction
'Usage
 
Dim instance As Worksheet
Dim row As Integer
Dim column As Integer
Dim rowCount As Integer
Dim columnCount As Integer
Dim stream As Stream
Dim flags As TextFileSaveFlags
Dim encoding As Encoding
Dim value As IAsyncAction
 
value = instance.SaveCsvAsync(row, column, rowCount, columnCount, stream, flags, encoding)
public IAsyncAction SaveCsvAsync( 
   int row,
   int column,
   int rowCount,
   int columnCount,
   Stream stream,
   TextFileSaveFlags flags,
   Encoding encoding
)

Parameters

row
The starting row index.
column
The starting column index.
rowCount
The number of rows.
columnCount
The number of columns.
stream
The stream to which to save the content.
flags
The export flags.
encoding
The encoding.
Example
This example uses the SaveCsvAsync method.
private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var filePicker = new Windows.Storage.Pickers.FileSavePicker();
                filePicker.FileTypeChoices.Add("CSV Files", new List<string>() { ".csv" });
                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.Sheets[0].SaveCsvAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.None);
                //await gcSpreadSheet1.Sheets[0].SaveCsvAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.None, System.Text.Encoding.UTF8);
                //await gcSpreadSheet1.Sheets[0].SaveCsvAsync(0, 0, 5, 5, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.None);
                //await gcSpreadSheet1.Sheets[0].SaveCsvAsync(0, 0, 5, 5, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.None, System.Text.Encoding.UTF8);
                //await gcSpreadSheet1.SaveCSVAsync(0, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.AsViewed);
                //await gcSpreadSheet1.SaveCSVAsync(0, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.AsViewed, System.Text.Encoding.UTF8);
                    }
                }
            }
            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("CSV Files", New List(Of String)() From {".csv"})
            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.Sheets(0).SaveCsvAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.AsViewed)
            'await GcSpreadSheet1.Sheets(0).SaveCsvAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.AsViewed, System.Text.Encoding.UTF8)
            'await GcSpreadSheet1.Sheets(0).SaveCsvAsync(0, 0, 5, 5, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.AsViewed)
            'await GcSpreadSheet1.Sheets(0).SaveCsvAsync(0, 0, 5, 5, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.AsViewed, System.Text.Encoding.UTF8)
            'await GcSpreadSheet1.SaveCSVAsync(0, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.AsViewed)
            'await GcSpreadSheet1.SaveCSVAsync(0, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.AsViewed, System.Text.Encoding.UTF8)
                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
Requirements

Target Platforms: Windows Server 2012, Windows RT

See Also

Reference

Worksheet Class
Worksheet Members
Overload List

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options