Other API Samples

Live SpreadsheetGear API Samples

Workbook Opening Opening from Stream or Byte Array

In addition to opening from disk, SpreadsheetGear can also open from a memory stream or byte array using the IWorkbooks.OpenFromStream(...) and OpenFromMemory(...) methods. You can access IWorkbooks and these methods by first creating an IWorkbookSet, as demonstrated below.

// First create an empty workbook set.
SpreadsheetGear.IWorkbookSet workbookSet = SpreadsheetGear.Factory.GetWorkbookSet();

// Open workbook file from a stream
SpreadsheetGear.IWorkbook workbook = workbookSet.Workbooks.OpenFromStream(stream);

// Open workbook file from a byte array
SpreadsheetGear.IWorkbook workbook = workbookSet.Workbooks.OpenFromStream(bytes);