Opens an ExcelWriter template from a . An ExcelWriter template is a file created in Microsoft Excel that contains data markers where data source values will be inserted.

 public virtual void Open(System.IO.Stream stream)
Public Overridable Sub Open(ByVal stream As System.IO.Stream)

A System.IO.Stream object, or a class derived from System.IO.Stream (for example, ).

Open will throw this exception if null (C#) or Nothing (VB.NET) is passed to the method.

If your template file is the new Office Open XML (.xlsx) format, you can pass it into the ExcelTemplate.Open method just as you would a BIFF8 (.xls) Excel file. You will need to remember to give the output file a ".xlsx" extension when you call Save, as ExcelWriter cannot convert .xlsx files to .xls.

          //--- Open an Excel BIFF8 (.xls) file
          FileStream oFileStream = New FileStream(@"C:\Templates\Template.xls", FileMode.Open);

          //--- Open an Office Open XML Excel (.xlsx) file
          FileStream oFileStream = New FileStream(@"C:\Templates\Template.xlsx", FileMode.Open);

          '--- Open an Excel BIFF8 (.xls) file
          Dim oFileStream As New FileStream("C:\Templates\Template.xls", FileMode.Open)

          '--- Open an Office Open XML Excel (.xlsx) file
          Dim oFileStream As New FileStream("C:\Templates\Template.xlsx", FileMode.Open)