Version

Load(Stream,IPackageFactory,Boolean) Method

Reads a workbook from a stream.
Syntax
'Declaration
 
Public Overloads Shared Function Load( _
   ByVal stream As Stream, _
   ByVal packageFactory As IPackageFactory, _
   ByVal verifyExcel2007Xml As Boolean _
) As Workbook
public static Workbook Load( 
   Stream stream,
   IPackageFactory packageFactory,
   bool verifyExcel2007Xml
)

Parameters

stream
The stream to read the workbook from.
packageFactory
An IPackageFactory which can be used to open an IPackage from a stream.
verifyExcel2007Xml
A boolean specifying whether or not to verify the contents of the markup against the rules defined in Part 2 of the 'Office Open XML - Open Packaging Conventions' document (see final draft, ECMA document TC45).

Return Value

The workbook loaded from the stream.
Exceptions
ExceptionDescription
System.ArgumentExceptionstream does not contain valid Microsoft Excel file contents.
System.ArgumentException The file format cannot be determined from the specified stream.
System.InvalidOperationException The format of the workbook data is in an unsupported format.
System.NotSupportedExceptionpackageFactory is null and the workbook being loaded is in an Excel 2007 format and the CLR 2.0 Excel assembly is being used. An Infragistics.Documents.Core.Packaging.IPackageFactory must be specified so the Excel 2007 file package can be accessed.
Infragistics.Documents.Core.DocumentEncryptedExceptionOccurs when the workbook is encrypted and no password was specified to open the stream via WorkbookLoadOptions.OpenPassword.
Infragistics.Documents.Core.EncryptionAlgorithmNotSupportedException Occurs when the workbook is encrypted with an unsupported encryption algorithm and cannot be decrypted.
Remarks

When loading the workbook, the format will be determined the file extension or by the contents of the file. If a FileStream is specified, the extension of the file will be examined. If the extension is a standard Excel format extension, the workbook will be assumed to be in the corresponding format. Otherwise, the contents of the file will be examined to try to determine the format. The CurrentFormat of the returned workbook will indicate the format the workbook was loaded from.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also