Spread Windows Forms 6.0 Product Documentation
LoadTextFile(Stream,TextFileFlags,IncludeHeaders,String,String,String) Method
See Also  Example Support Options
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > SheetView Class > LoadTextFile Method : LoadTextFile(Stream,TextFileFlags,IncludeHeaders,String,String,String) Method


stream
Stream to which to save the text of the sheet
textFileFlags
Specifies how to process the data when loading from a text file
includeHeaders
Whether to export headers as data
rowDelimiter
Row delimiter string
columnDelimiter
Column delimiter string
cellDelimiter
Cell delimiter string

Glossary Item Box

Loads delimited text from a specified file into the sheet, with or without headers, with the specified encoding.

Syntax

Visual Basic (Declaration) 
Public Overloads Sub LoadTextFile( _
   ByVal stream As Stream, _
   ByVal textFileFlags As TextFileFlags, _
   ByVal includeHeaders As IncludeHeaders, _
   ByVal rowDelimiter As String, _
   ByVal columnDelimiter As String, _
   ByVal cellDelimiter As String _
) 
Visual Basic (Usage)Copy Code
Dim instance As SheetView
Dim stream As Stream
Dim textFileFlags As TextFileFlags
Dim includeHeaders As IncludeHeaders
Dim rowDelimiter As String
Dim columnDelimiter As String
Dim cellDelimiter As String
 
instance.LoadTextFile(stream, textFileFlags, includeHeaders, rowDelimiter, columnDelimiter, cellDelimiter)
C# 
public void LoadTextFile( 
   Stream stream,
   TextFileFlags textFileFlags,
   IncludeHeaders includeHeaders,
   string rowDelimiter,
   string columnDelimiter,
   string cellDelimiter
)

Parameters

stream
Stream to which to save the text of the sheet
textFileFlags
Specifies how to process the data when loading from a text file
includeHeaders
Whether to export headers as data
rowDelimiter
Row delimiter string
columnDelimiter
Column delimiter string
cellDelimiter
Cell delimiter string

Exceptions

ExceptionDescription
System.ArgumentException Cell delimiter cannot be contained in a row or column delimiter

Example

This example loads a text file.
C#Copy Code
OpenFileDialog ofd = new OpenFileDialog();
System.IO.Stream s;
ofd.Filter = "text files (*.txt)|*.txt";
ofd.FilterIndex = 2;
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
   s = ofd.OpenFile();
   fpSpread1.ActiveSheet.LoadTextFile(s, FarPoint.Win.Spread.TextFileFlags.Unformatted, FarPoint.Win.Spread.Model.IncludeHeaders.None, "\n", ",", "");
   s.Close();
}
Visual BasicCopy Code
Dim s As System.IO.Stream
Dim ofd As New OpenFileDialog()
ofd.Filter = "text files (*.txt)|*.txt"
ofd.FilterIndex = 2
ofd.RestoreDirectory = True
If ofd.ShowDialog() = DialogResult.OK Then
    s = ofd.OpenFile
    FpSpread1.ActiveSheet.LoadTextFile(s, FarPoint.Win.Spread.TextFileFlags.Unformatted, FarPoint.Win.Spread.Model.IncludeHeaders.None, Chr(10), ",", "")
    s.Close()
End If

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

© 2002-2012 ComponentOne, a division of GrapeCity. All Rights Reserved.