Version

Load(String,WorkbookLoadOptions) Method

Reads a workbook from a file.
Syntax
'Declaration
 
Public Overloads Shared Function Load( _
   ByVal fileName As System.String, _
   Optional ByVal loadOptions As WorkbookLoadOptions _
) As Workbook
public static Workbook Load( 
   System.string fileName,
   WorkbookLoadOptions loadOptions
)

Parameters

fileName
The file from which to read the workbook.
loadOptions
The options to use to load the file or null to use the default options.

Return Value

The workbook loaded from the file.
Exceptions
ExceptionDescription
System.ArgumentExceptionfileName is a path to an invalid Microsoft Excel file.
System.ArgumentException The file format cannot be determined from the specified file.
System.InvalidOperationException The format of the workbook data is in an unsupported format.
System.NotSupportedExceptionThe workbook being loaded is in an Excel 2007 format and the CLR 2.0 Excel assembly is being used. The overload taking an Infragistics.Documents.Core.Packaging.IPackageFactory must be used in this case so the Excel 2007 file package can be accessed.
Infragistics.Documents.Core.InvalidPasswordExceptionOccurs when the workbook is encrypted and the open password specified in the loadOptions is not correct.
Infragistics.Documents.Core.DocumentEncryptedExceptionOccurs when the workbook is encrypted and no password was specified to open the file in the loadOptions.
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 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.

Note: This method creates a System.IO.FileStream using the FileStream(string, FileMode) overload of the constructor. See the remarks section of this overload for the exceptions that could be thrown.

Requirements

Target Platforms: Windows 8.1, 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

View on GitHub