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: