Spread WPF Documentation
SaveTextFileRange(Int32,Int32,Int32,Int32,Stream,TextFileSaveFlags,String,String,String,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 range text.
The export flags.
The row delimiter string.
The column delimiter string.
The cell delimiter string.
The encoding.
Saves the range of cells in the sheet as delimited text and saves to a stream with the specified delimiters and encoding.
Syntax
'Declaration
 
Public Overloads Sub SaveTextFileRange( _
   ByVal row As System.Integer, _
   ByVal column As System.Integer, _
   ByVal rowCount As System.Integer, _
   ByVal columnCount As System.Integer, _
   ByVal stream As System.IO.Stream, _
   ByVal flags As TextFileSaveFlags, _
   ByVal rowDelimiter As System.String, _
   ByVal columnDelimiter As System.String, _
   ByVal cellDelimiter As System.String, _
   ByVal encoding As System.Text.Encoding _
) 
'Usage
 
Dim instance As Worksheet
Dim row As System.Integer
Dim column As System.Integer
Dim rowCount As System.Integer
Dim columnCount As System.Integer
Dim stream As System.IO.Stream
Dim flags As TextFileSaveFlags
Dim rowDelimiter As System.String
Dim columnDelimiter As System.String
Dim cellDelimiter As System.String
Dim encoding As System.Text.Encoding
 
instance.SaveTextFileRange(row, column, rowCount, columnCount, stream, flags, rowDelimiter, columnDelimiter, cellDelimiter, encoding)
public void SaveTextFileRange( 
   System.int row,
   System.int column,
   System.int rowCount,
   System.int columnCount,
   System.IO.Stream stream,
   TextFileSaveFlags flags,
   System.string rowDelimiter,
   System.string columnDelimiter,
   System.string cellDelimiter,
   System.Text.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 range text.
flags
The export flags.
rowDelimiter
The row delimiter string.
columnDelimiter
The column delimiter string.
cellDelimiter
The cell delimiter string.
encoding
The encoding.

Return Value

true if the data is saved to the stream successfully; otherwise, false.
Exceptions
ExceptionDescription
System.ArgumentException Cell delimiter cannot be contained in a row or column delimiter.
Remarks
Note that the cell delimiter cannot be contained in a row or column delimiter.
Example
This example uses the SaveTextFileRange 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 void button1_Click(object sender, RoutedEventArgs e)
{
string fileName;
fileName = "c:\\zipfile\\savespreadstream.csv";
System.IO.Stream stream;
stream = System.IO.File.Create(fileName);
gcSpreadSheet1.Sheets[0].SaveTextFileRange(0, 0, 5, 5, stream, GrapeCity.Windows.SpreadSheet.Data.TextFileSaveFlags.AsViewed , "\r", ",", "", System.Text.Encoding.ASCII);
//gcSpreadSheet1.Sheets[0].SaveTextFileRange(0, 0, 5, 5, stream, GrapeCity.Windows.SpreadSheet.Data.TextFileSaveFlags.AsViewed , "\r", ",", "");
}
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 Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim fileName As String
fileName = "c:\zipfile\savespreadstream.csv"
Dim stream As System.IO.Stream
stream = System.IO.File.Create(fileName, System.IO.FileMode.Create)
GcSpreadSheet1.Sheets(0).SaveTextFileRange(0, 0, 5, 5, stream, GrapeCity.Windows.SpreadSheet.Data.TextFileSaveFlags.AsViewed, Chr(13), ",", "", System.Text.Encoding.ASCII)
'GcSpreadSheet1.Sheets(0).SaveTextFileRange(0, 0, 5, 5, stream, GrapeCity.Windows.SpreadSheet.Data.TextFileSaveFlags.AsViewed, Chr(13), ",", "")
GcSpreadSheet1.Invalidate()
End Sub
Requirements

Target Platforms: Windows 7, Windows 8 Desktop, Windows Vista SP1 or later, Windows Server 2000, Windows 2000 Professional (SP4), Windows XP (SP2), Windows 2008, Windows 2003 Server (SP1)

See Also

Reference

Worksheet Class
Worksheet Members
Overload List

 

 


Copyright © GrapeCity, inc. All rights reserved.