GrapeCity.Xaml.SpreadSheet.UI Namespace > GcSpreadSheet Class > OpenCSVAsync Method : OpenCSVAsync(Int32,Stream,TextFileOpenFlags) Method |
'Declaration Public Overloads Function OpenCSVAsync( _ ByVal sheetIndex As Integer, _ ByVal stream As Stream, _ ByVal flags As TextFileOpenFlags _ ) As IAsyncAction
'Usage Dim instance As GcSpreadSheet Dim sheetIndex As Integer Dim stream As Stream Dim flags As TextFileOpenFlags Dim value As IAsyncAction value = instance.OpenCSVAsync(sheetIndex, stream, flags)
public IAsyncAction OpenCSVAsync( int sheetIndex, Stream stream, TextFileOpenFlags flags )
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.None); //await gcSpreadSheet1.Sheets[0].OpenCsvAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.None, System.Text.Encoding.UTF8); //await gcSpreadSheet1.OpenCSVAsync(0, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.None); //await gcSpreadSheet1.OpenCSVAsync(0, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.None); } } } 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.None) 'await GcSpreadSheet1.Sheets(0).OpenCsvAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.None, System.Text.Encoding.UTF8) 'await GcSpreadSheet1.OpenCSVAsync(0, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.None) 'await GcSpreadSheet1.OpenCSVAsync(0, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileOpenFlags.None, 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
Target Platforms: Windows Server 2012, Windows RT