[]
Opens a workbook file.
This method opens the specified file by using the default open options. The file type is inferred from the file name extension.
The fileName value is used directly as a file system path.
Pass only validated paths from trusted sources.
void Open(string fileName)
Sub Open(fileName As String)
| Type | Name | Description |
|---|---|---|
| string | fileName | The path and name of the workbook file to open. Must not be |
workbook.Open(Path.Combine(Environment.CurrentDirectory, "QuarterlyReport.xlsx"));
string fullName = workbook.FullName;
Opens the specified JSON file using the provided deserialization options.
Uses the provided DeserializationOptions to control how the JSON content is deserialized into the workbook.
IList<JsonError> Open(string fileName, DeserializationOptions deserializationOptions)
Function Open(fileName As String, deserializationOptions As DeserializationOptions) As IList(Of JsonError)
| Type | Name | Description |
|---|---|---|
| string | fileName | The JSON file to open. |
| DeserializationOptions | deserializationOptions | The options that control JSON deserialization. |
| Type | Description |
|---|---|
| IList<JsonError> | A list of JsonError objects generated while opening the JSON file. |
DeserializationOptions options = new DeserializationOptions();
options.IgnoreStyle = true;
IList<JsonError> errors = workbook.Open("spread_js_exported.json", options);
Opens the specified Excel file with an optional password and open options.
Use this overload to open a password-protected workbook from the specified file path. You can also provide OpenOptions to control how the workbook is loaded.
This method is obsolete. Use Open(string, OpenOptionsBase) instead.
[Obsolete("Use Open(string, OpenOptionsBase) instead.")]
void Open(string fileName, string password = null, OpenOptions openOptions = null)
<Obsolete("Use Open(string, OpenOptionsBase) instead.")>
Sub Open(fileName As String, Optional password As String = Nothing, Optional openOptions As OpenOptions = Nothing)
| Type | Name | Description |
|---|---|---|
| string | fileName | The path and name of the Excel file to open. Must not be null. |
| string | password | The password for the file. Use the password required by the workbook; null if no password is needed. |
| OpenOptions | openOptions | The open options for the file. Use null to apply no explicit open options. |
Opens the specified Excel file stream.
Use this method to load workbook data from a Stream.
void Open(Stream fileStream)
Sub Open(fileStream As Stream)
| Type | Name | Description |
|---|---|---|
| Stream | fileStream | The stream that contains the Excel file data. Must not be null. |
worksheet.Range["A1"].Value = "Name";
MemoryStream stream = new MemoryStream();
workbook.Save(stream, SaveFileFormat.Xlsx);
stream.Position = 0;
IWorkbook openedWorkbook = new Workbook();
openedWorkbook.Open(stream);
Opens the specified excel file stream.
[Obsolete("Use Open(Stream, OpenOptionsBase) instead.")]
void Open(Stream fileStream, string password = null, OpenOptions openOptions = null)
<Obsolete("Use Open(Stream, OpenOptionsBase) instead.")>
Sub Open(fileStream As Stream, Optional password As String = Nothing, Optional openOptions As OpenOptions = Nothing)
| Type | Name | Description |
|---|---|---|
| Stream | fileStream | The file stream. |
| string | password | The password of the file. |
| OpenOptions | openOptions | Options for opening. |
Opens a file using the specified file format.
Use this overload when the file format should be provided explicitly instead of being inferred from the file name.
void Open(string fileName, OpenFileFormat fileFormat)
Sub Open(fileName As String, fileFormat As OpenFileFormat)
| Type | Name | Description |
|---|---|---|
| string | fileName | The path of the workbook file to open. |
| OpenFileFormat | fileFormat | The format of the file. |
IWorkbook openedWorkbook = new Workbook();
openedWorkbook.Open("Template.sjs", OpenFileFormat.Sjs);
IWorksheet firstSheet = openedWorkbook.Worksheets[0];
Opens the specified format file stream.
void Open(Stream fileStream, OpenFileFormat fileFormat)
Sub Open(fileStream As Stream, fileFormat As OpenFileFormat)
| Type | Name | Description |
|---|---|---|
| Stream | fileStream | The specified file stream. |
| OpenFileFormat | fileFormat | The format of the file stream. |
worksheet.Range["A1"].Value = "Template";
using (MemoryStream stream = new MemoryStream())
{
workbook.Save(stream, SaveFileFormat.Sjs);
stream.Position = 0;
IWorkbook openedWorkbook = new Workbook();
openedWorkbook.Open(stream, OpenFileFormat.Sjs);
}
Opens a file with the specified open options.
Use this overload to control how the workbook is loaded for supported file formats.
void Open(string fileName, OpenOptionsBase options)
Sub Open(fileName As String, options As OpenOptionsBase)
| Type | Name | Description |
|---|---|---|
| string | fileName | The path of the workbook file to open. |
| OpenOptionsBase | options | The open options for the file. Possible types: |
XlsxOpenOptions options = new XlsxOpenOptions();
options.DoNotRecalculateAfterOpened = true;
string fileName = Path.Combine(Environment.CurrentDirectory, "OpenWorkbookWithOptions.xlsx");
IWorkbook openedWorkbook = new Workbook();
openedWorkbook.Open(fileName, options);
Opens the stream with specified options.
void Open(Stream fileStream, OpenOptionsBase options)
Sub Open(fileStream As Stream, options As OpenOptionsBase)
| Type | Name | Description |
|---|---|---|
| Stream | fileStream | The file stream. |
| OpenOptionsBase | options | The options used when opening the file stream. Possible types: |
worksheet.Range["A1"].Value = "Open with options";
using (MemoryStream stream = new MemoryStream())
{
workbook.Save(stream);
stream.Position = 0;
XlsxOpenOptions options = new XlsxOpenOptions();
options.DoNotRecalculateAfterOpened = true;
IWorkbook openedWorkbook = new Workbook();
openedWorkbook.Open(stream, options);
}