GrapeCity.Xaml.SpreadSheet.Data
OpenCsvAsync(Stream,TextFileOpenFlags,Encoding) Method
Example 


The stream from which to load to file.
The import flags.
The encoding.
Loads the CSV (comma-separated values) file asynchronously.
Syntax
'Declaration
 
Public Overloads Function OpenCsvAsync( _
   ByVal stream As Stream, _
   ByVal flags As TextFileOpenFlags, _
   ByVal encoding As Encoding _
) As IAsyncAction
'Usage
 
Dim instance As Worksheet
Dim stream As Stream
Dim flags As TextFileOpenFlags
Dim encoding As Encoding
Dim value As IAsyncAction
 
value = instance.OpenCsvAsync(stream, flags, encoding)
public IAsyncAction OpenCsvAsync( 
   Stream stream,
   TextFileOpenFlags flags,
   Encoding encoding
)

Parameters

stream
The stream from which to load to file.
flags
The import flags.
encoding
The encoding.
Example
This example uses the OpenCsvAsync method.
private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var filePicker = new Windows.Storage.Pickers.FileOpenPicker();
                filePicker.FileTypeFilter.Add(".csv");                
                Windows.Storage.StorageFile storageFile = await filePicker.PickSingleFileAsync();
                if (storageFile != null)
                {
                    using (var stream = await storageFile.OpenStreamForReadAsync())
                    {
                        await gcSpreadSheet1.Sheets[0].OpenCsvAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.IncludeColumnHeader);
//await gcSpreadSheet1.Sheets[0].OpenCsvAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.IncludeColumnHeader, 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.FileOpenPicker()
            filePicker.FileTypeFilter.Add(".csv")
            Dim storageFile As Windows.Storage.StorageFile = Await filePicker.PickSingleFileAsync()
            If storageFile IsNot Nothing Then
                Using stream = Await storageFile.OpenStreamForReadAsync()
                    await GcSpreadSheet1.Sheets(0).OpenCsvAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.IncludeColumnHeader)
'await GcSpreadSheet1.Sheets(0).OpenCsvAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.IncludeColumnHeader, 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