Spread Silverlight Documentation
Opening and Saving Text Files
Spread Silverlight Documentation > Developer's Guide > Managing Data > Opening and Saving Text Files

You can load or save text files. You can specify the open or save flags as well as the column, row, and cell delimiters. You can also specify the encoding.

You can use the OpenTextFile method to load text files and the SaveTextFileRange method to save text files.

Using Code

The following example opens a text file.

CS
Copy Code

OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Text File (.txt)|*.txt";
bool? useClick = openFileDialog.ShowDialog();
if (useClick == true)
{
    var stream = openFileDialog.File.OpenRead();
    stream.Seek(0, System.IO.SeekOrigin.Begin);
gcSpreadSheet1.Sheets[0].OpenTextFile(stream, GrapeCity.Windows.SpreadSheet.Data.TextFileOpenFlags.None, "\r", ",", "");

stream.Dispose();
}

VB.NET
Copy Code

Dim openFileDialog = New OpenFileDialog()
openFileDialog.Filter = "Text File(.txt)|*.txt"
Dim useClick As Boolean = openFileDialog.ShowDialog()
If (useClick = True) Then
    Dim stream = openFileDialog.File.OpenRead()
    stream.Seek(0, IO.SeekOrigin.Begin)GcSpreadSheet1.Sheets(0).OpenTextFile(stream, GrapeCity.Windows.SpreadSheet.Data.TextFileOpenFlags.None, ChrW(13), ",", "")

End If

See Also