Other API Samples C# logo

Opening from Stream or Byte Array SpreadsheetGear API Sample

Description

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.

Sample Source Code

// 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.OpenFromMemory(bytes);