Load and Export CSV format

To load CSV format into worksheet, use one of following method from both workbook and worksheet object.

  • Workbook.Load
  • Worksheet.LoadCSV

The method of workbook that loads all data from CSV to replace current workbook, all worksheets and data existed in the workbook will be deleted; the workbook will be reset.

The method of worksheet that loads and fills all data from CSV into one worksheet, other worksheet existing in same workbook will not be affected.

Load CSV to workbook

Use method Load of workbook load CSV data from file or stream into workbook.

void Load(Stream s, ReoGridFormat format);
void Load(string path, ReoGridFormat format = ReoGridFormat.CSV)

High Importance-20 Since CSV format doesn’t support multiple worksheet, all existing worksheets in the workbook will be removed, a new worksheet will be created to load the CSV content. If load from file, the file name will be used as sheet name automatically.

Load CSV to worksheet

To load CSV into specified worksheet, use one of following methods:

// load from stream
void LoadCSV(Stream s);

// load from file
void LoadCSV(string path);

// load from stream and convert string by specified encoding
void LoadCSV(Stream s, Encoding encoding);

// load from path and convert string by specified encoding
public void LoadCSV(string path, Encoding encoding);

// load from stream by specifying autoSpread, bufferLines and encoding
public void LoadCSV(Stream s, bool autoSpread, int bufferLines, Encoding encoding);

Since CSV will be read as plain-text format, it is better to specify a text encoding for loading and saving. For example, load from file by using Japanese encoding “shift-jis”:

worksheet.LoadCSV(@"G:\ReoGrid\Samples\13TOKYO.CSV", Encoding.GetEncoding("shift-jis"));



Export as CSV

There is no way to export data from multiple worksheet to a CSV file, it is nessaray to export data from each worksheet. To export as CSV from a worksheet, use method ExportAsCSV of worksheet:

worksheet.ExportAsCSV(Stream steam);
worksheet.ExportAsCSV(string filepath);

Automatic Expansion

By default, ReoGrid will expand the size of worksheet in order to load and fill all data from a CSV. To disable this behavior, set the autoSpread argument to false.