Articles in this section
Category / Section

How to serialize or deserialize in WinForms Spreadsheet (SfSpreadsheet)?

1 min read

Serialization and deserialization in spreadsheet

Spreadsheet provides support to serialize and deserialize the workbook using XlsIO.

 

Serialization:

For serialization, you can use SaveAsXml() method of IWorkbook.

C#

// Serialize
MemoryStream serializedBinary = new MemoryStream();
this.Spreadsheet.Workbook.SaveAsXml(serializedBinary, ExcelXmlSaveType.MSExcel);

 

Deserialization:

For Deserialization, you can use OpenFromXml() method of IWorkbook .

C#

// Deserialize
serializedBinary.Seek(0, SeekOrigin.Begin);
ExcelEngine engine = new ExcelEngine();
IWorkbook workbook = engine.Excel.Workbooks.OpenFromXml(serializedBinary, ExcelXmlOpenType.MSExcel);
this.Spreadsheet.Open(workbook);

Samples:

WPF

WinForms

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied