Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Description

Excerpt

Opens an existing Excel spreadsheet.

Signature
C#
C#
 public virtual Workbook Open(System.String fileName, System.String decryptPassword)
{signature}{signature:
}
Signature
vb.net
vb.net
Public Overridable Function Open(ByVal fileName As String, ByVal decryptPassword As String) As Workbook
{signature}
{parameters}
{param:fileName}The path and name of the file to open. The path can be relative or absolute. The file must be a OOXML format \(Excel 2007 or later\) .xlsx file or BIFF8 format \(Excel 97 or later\) .xls file.{param}
{param:decryptPassword}The password used to encrypt the spreadsheet. Standard "Office 97/2000 Compatible" encryption is used  to encrypt the spreadsheet. This is the default encryption used by Excel 97 and later versions.{param}
{returns}A [Workbook|Workbook] object representing the file opened.{returns}
{exceptions}
{exception:System.Exception}If the file cannot be found or opened, or if the file is not a OOXML format \(Excel 2007 or later\) .xlsx or BIFF8 format \(Excel 97 or later\) .xls file.{exception}
{exception:ArgumentException}
If {{decryptPassword}} is not the password that can decrypt the workbook.
{exception}
{remarks}ExcelWriter supports  Excel's OOXML \(Excel 2007 or later\) and BIFF8 \(Excel 97 or later\) format only.  Do not use  this method  to open BIFF7 \(Excel 95\) files.

Note that ExcelWriter will not automatically re-encrypt a workbook that was opened with this method.  If you want to ensure that your workbook is encrypted when saved, set the [{{EncryptPassword}}|Workbook.EncryptPassword] property.
{remarks}
{example}{code:csharp|title=C#}
Parameters
Param
fileName
fileName

The path and name of the file to open. The path can be relative or absolute. The file must be a OOXML format (Excel 2007 or later) .xlsx file or BIFF8 format (Excel 97 or later) .xls file.

Param
decryptPassword
decryptPassword

The password used to encrypt the spreadsheet. Standard "Office 97/2000 Compatible" encryption is used to encrypt the spreadsheet. This is the default encryption used by Excel 97 and later versions.

Returns

A Workbook object representing the file opened.

Exceptions
Exception
System.Exception
System.Exception

If the file cannot be found or opened, or if the file is not a OOXML format (Excel 2007 or later) .xlsx or BIFF8 format (Excel 97 or later) .xls file.

Exception
ArgumentException
ArgumentException

If decryptPassword is not the password that can decrypt the workbook.

Remarks

ExcelWriter supports Excel's OOXML (Excel 2007 or later) and BIFF8 (Excel 97 or later) format only. Do not use this method to open BIFF7 (Excel 95) files.

Note that ExcelWriter will not automatically re-encrypt a workbook that was opened with this method. If you want to ensure that your workbook is encrypted when saved, set the EncryptPassword property.

Example
Code Block
csharp
csharp
titleC#


          ExcelApplication xla = new ExcelApplication();
          Workbook wb = xla.Open(@"C:\Reports\Report.xlsx", "MyPassword");
        
{code} {code:
Code Block
vb.net
|title=
vb.net
titlevb.net
}


          Dim xla As New ExcelApplication()
          Dim wb As Workbook = xla.Open("C:\Reports\Report.xlsx", "MyPassword")
        
{code} {example}