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


The stream from which to load data.
The import flags.
The row delimiter string.
The column delimiter string.
The cell delimiter string.
The encoding.
Loads delimited text from a specified stream into the sheet, with or without headers, with the specified encoding asynchronously.
Syntax
'Declaration
 
Public Overloads Function OpenTextFileAsync( _
   ByVal stream As Stream, _
   ByVal flags As TextFileOpenFlags, _
   ByVal rowDelimiter As String, _
   ByVal columnDelimiter As String, _
   ByVal cellDelimiter As String, _
   ByVal encoding As Encoding _
) As IAsyncAction
'Usage
 
Dim instance As Worksheet
Dim stream As Stream
Dim flags As TextFileOpenFlags
Dim rowDelimiter As String
Dim columnDelimiter As String
Dim cellDelimiter As String
Dim encoding As Encoding
Dim value As IAsyncAction
 
value = instance.OpenTextFileAsync(stream, flags, rowDelimiter, columnDelimiter, cellDelimiter, encoding)
public IAsyncAction OpenTextFileAsync( 
   Stream stream,
   TextFileOpenFlags flags,
   string rowDelimiter,
   string columnDelimiter,
   string cellDelimiter,
   Encoding encoding
)

Parameters

stream
The stream from which to load data.
flags
The import flags.
rowDelimiter
The row delimiter string.
columnDelimiter
The column delimiter string.
cellDelimiter
The cell delimiter string.
encoding
The encoding.
Example
This example uses the OpenTextFileAsync method.
private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var filePicker = new Windows.Storage.Pickers.FileOpenPicker();
                filePicker.FileTypeFilter.Add(".txt");                
                Windows.Storage.StorageFile storageFile = await filePicker.PickSingleFileAsync();
                if (storageFile != null)
                {
                    using (var stream = await storageFile.OpenStreamForReadAsync())
                    {
await gcSpreadSheet1.Sheets[0].OpenTextFileAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.None, "\r", ",", "");
//await gcSpreadSheet1.Sheets[0].OpenTextFileAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.None, "\r", ",", "", System.Text.Encoding.UTF8);
//await gcSpreadSheet1.OpenTextFileAsync(0, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.None, "\r", ",", "");
                    }
                }
            }
            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(".txt")
            Dim storageFile As Windows.Storage.StorageFile = Await filePicker.PickSingleFileAsync()
            If storageFile IsNot Nothing Then
                Using stream = Await storageFile.OpenStreamForReadAsync()
                    await GcSpreadSheet1.Sheets(0).OpenTextFileAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.None, ChrW(13), ",", "")
                   'await GcSpreadSheet1.Sheets(0).OpenTextFileAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.None, ChrW(13), ",", "", System.Text.Encoding.UTF8)
                   'await GcSpreadSheet1.OpenTextFileAsync(0, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.None, ChrW(13), ",", "")
                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