Category / Section
How to serialize or deserialize in WinForms Spreadsheet?
2 mins read
Serialization and deserialization in spreadsheet
WinForms Spreadsheet (SfSpreadsheet) provides support to serialize and deserialize the workbook using XlsIO.
Serialization:
For serialization, you can use SaveAsXml method of IWorkbook.
// Serialize
MemoryStream serializedBinary = new MemoryStream();
this.Spreadsheet.Workbook.SaveAsXml(serializedBinary, ExcelXmlSaveType.MSExcel);
Deserialization:
For Deserialization, you can use OpenFromXml method of IWorkbook.
// Deserialize
serializedBinary.Seek(0, SeekOrigin.Begin);
ExcelEngine engine = new ExcelEngine();
IWorkbook workbook = engine.Excel.Workbooks.OpenFromXml(serializedBinary, ExcelXmlOpenType.MSExcel);
this.Spreadsheet.Open(workbook);
Samples: