GrapeCity.Xaml.SpreadSheet.Data
SaveTextFileRangeAsync(Int32,Int32,Int32,Int32,Stream,TextFileSaveFlags,String,String,String) Method
Example 


GrapeCity.Xaml.SpreadSheet.Data Namespace > Worksheet Class > SaveTextFileRangeAsync Method : SaveTextFileRangeAsync(Int32,Int32,Int32,Int32,Stream,TextFileSaveFlags,String,String,String) Method
The starting row index.
The starting column index.
The number of rows.
The number of columns.
The stream to which to save the text of the range.
The export flags.
The row delimiter string.
The column delimiter string.
The cell delimiter string.
Saves the range of cells in the sheet as delimited text and saves to a stream with the specified delimiters asynchronously.
Syntax
'Declaration
 
Public Overloads Function SaveTextFileRangeAsync( _
   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 rowDelimiter As String, _
   ByVal columnDelimiter As String, _
   ByVal cellDelimiter As String _
) 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 rowDelimiter As String
Dim columnDelimiter As String
Dim cellDelimiter As String
Dim value As IAsyncAction
 
value = instance.SaveTextFileRangeAsync(row, column, rowCount, columnCount, stream, flags, rowDelimiter, columnDelimiter, cellDelimiter)
public IAsyncAction SaveTextFileRangeAsync( 
   int row,
   int column,
   int rowCount,
   int columnCount,
   Stream stream,
   TextFileSaveFlags flags,
   string rowDelimiter,
   string columnDelimiter,
   string cellDelimiter
)

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 text of the range.
flags
The export flags.
rowDelimiter
The row delimiter string.
columnDelimiter
The column delimiter string.
cellDelimiter
The cell delimiter string.
Example
This example uses the SaveTextFileRangeAsync method.
gcSpreadSheet1.Sheets[0].Cells[0, 0].Value = "test";
gcSpreadSheet1.Sheets[0].Cells[0, 2].Value = "test1";
gcSpreadSheet1.Sheets[0].Cells[1, 0].Value = "test2";
       
private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var filePicker = new Windows.Storage.Pickers.FileSavePicker();
                filePicker.FileTypeChoices.Add("Text Files", new List<string>() { ".txt" });
                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].SaveTextFileRangeAsync(0, 0, 5, 5, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.AsViewed, "\r", ",", "", System.Text.Encoding.UTF8);
                        //await gcSpreadSheet1.Sheets[0].SaveTextFileRangeAsync(0, 0, 5, 5, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.AsViewed , "\r", ",", "");
                    }
                }
            }
            catch (Exception ex)
            {
                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(ex.Message, "Error");
                dialog.ShowAsync();
            }           
        }
GcSpreadSheet1.Sheets(0).Cells(0, 0).Value = "test"
GcSpreadSheet1.Sheets(0).Cells(0, 2).Value = "test1"
GcSpreadSheet1.Sheets(0).Cells(1, 0).Value = "test2"

Private Async Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        Try
            Dim filePicker As New Windows.Storage.Pickers.FileSavePicker()
            filePicker.FileTypeChoices.Add("Text Files", New List(Of String)() From {".txt"})
            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).SaveTextFileRangeAsync(0, 0, 5, 5, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.AsViewed, ChrW(13), ",", "", System.Text.Encoding.UTF8)
                   'await GcSpreadSheet1.Sheets(0).SaveTextFileRangeAsync(0, 0, 5, 5, stream, GrapeCity.Xaml.SpreadSheet.Data.TextFileSaveFlags.AsViewed, 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
See Also

Reference

Worksheet Class
Worksheet Members
Overload List