ReoGrid supports the following file formats:
| Format | Read Workbook | Write Workbook | Read Worksheet | Write Worksheet |
|---|
| Excel 2007 (Open Office XML, .xlsx) | Yes | Yes | | |
| RGF (ReoGrid Format, XML-based) | Yes | Yes | Yes | Yes |
| CSV | | | Yes | Yes |
| HTML | | | | Yes |
using unvell.ReoGrid.IO;
| Value | Description |
|---|
FileFormat.Excel2007 | Excel 2007+ Open XML format (.xlsx) |
FileFormat.ReoGridFormat | ReoGrid native format (XML-based, .rgf) |
FileFormat.CSV | Comma-separated values |
Workbook Load / Save
Load
// Auto-detect format from file extension
grid.Load("file.xlsx");
// Specify format explicitly
grid.Load("file.xlsx", FileFormat.Excel2007);
// From a stream (format required)
grid.Load(stream, FileFormat.Excel2007);
// With encoding
grid.Load(stream, FileFormat.CSV, Encoding.UTF8);
Load Overloads
| Signature | Description |
|---|
Load(string path) | Load from file, format detected from extension |
Load(string path, FileFormat format) | Load from file with explicit format |
Load(string path, FileFormat format, Encoding encoding) | Load with encoding |
Load(Stream stream, FileFormat format) | Load from stream |
Load(Stream stream, FileFormat format, Encoding encoding) | Load from stream with encoding |
Save
// Auto-detect format from file extension
grid.Save("output.xlsx");
// Specify format explicitly
grid.Save("output.xlsx", FileFormat.Excel2007);
// To a stream (format required)
grid.Save(stream, FileFormat.Excel2007);
Save Overloads
| Signature | Description |
|---|
Save(string path) | Save to file, format detected from extension |
Save(string path, FileFormat format) | Save to file with explicit format |
Save(string path, FileFormat format, Encoding encoding) | Save with encoding |
Save(Stream stream, FileFormat format) | Save to stream |
Save(Stream stream, FileFormat format, Encoding encoding) | Save to stream with encoding |
Worksheet-Level Load / Save (RGF Only)
For the RGF format, you can save and load individual worksheets:
// Save a single worksheet
sheet.SaveRGF("sheet1.rgf");
sheet.SaveRGF(stream);
// Load into a single worksheet
sheet.LoadRGF("sheet1.rgf");
sheet.LoadRGF(stream);
See RGF Format for details on multi-worksheet patterns.
Events
| Event | Description |
|---|
WorkbookLoaded | Raised after a workbook file is loaded |
WorkbookSaved | Raised after a workbook file is saved |
To learn about the differences between the Excel and RGF formats, see Difference between Excel and RGF format.