Spread Silverlight Documentation
Importing and Exporting CSV Files

GcSpreadSheet has additional settings that are available when saving or loading CSV files. You can only save or load text, include row or column headers, save or load unformatted values, export or import formulas, and set the encoding.

You can use the OpenCsv or SaveCsv method in code.

Using Code

The following example uses the OpenCsv and SaveCsv methods to open and save a file.

CS
Copy Code
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "csv File (.csv)|*.csv";
bool? useClick = saveFileDialog.ShowDialog();
if (useClick == true)
            {
var stream = saveFileDialog.OpenFile();
gcSpreadSheet1.Sheets[0].SaveCsv(stream, GrapeCity.Windows.SpreadSheet.Data.TextFileSaveFlags.None);
stream.Dispose();
            }
or
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "csv File (.csv)|*.csv";
bool? useClick = openFileDialog.ShowDialog();
            if (useClick == true)
            {
var stream = openFileDialog.File.OpenRead();
stream.Seek(0, System.IO.SeekOrigin.Begin);
gcSpreadSheet1.Sheets[0].OpenCsv(stream, GrapeCity.Windows.SpreadSheet.Data.TextFileOpenFlags.None);
stream.Dispose();
            }
VB.NET
Copy Code
Dim saveFileDialog = New SaveFileDialog()
saveFileDialog.Filter = "csv File(.csv)|*.csv"
Dim useClick As Boolean = saveFileDialog.ShowDialog()
        If (useClick = True) Then
Dim stream = saveFileDialog.OpenFile()
GcSpreadSheet1.Sheets(0).SaveCsv(stream, GrapeCity.Windows.SpreadSheet.Data.TextFileSaveFlags.None)
         End If
or

Dim openFileDialog = New OpenFileDialog()
        openFileDialog.Filter = "csv File(.csv)|*.csv"
        Dim useClick As Boolean = openFileDialog.ShowDialog()
        If (useClick = True) Then
            Dim stream = openFileDialog.File.OpenRead()
            stream.Seek(0, IO.SeekOrigin.Begin)
            GcSpreadSheet1.Sheets(0).OpenCsv(stream, GrapeCity.Windows.SpreadSheet.Data.TextFileOpenFlags.None)                     
        End If
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options | Documentation Feedback