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 ExcelWriter template from a

Msdn
System.IO.Stream

...

System.IO.Stream

...

1System.IO.Stream
. An ExcelWriter template is a file created in Microsoft Excel that contains data markers where data source values will be inserted.

Signature
C#
C#
 public virtual void Open(System.IO.Stream stream)
{signature}
{signature:
}
Signature
vb.net
vb.net
Public Overridable Sub Open(ByVal stream As System.IO.Stream)
{signature}
{parameters}
{param:templateStream}A {{
Parameters
Param
templateStream
templateStream

A System.IO.Stream

}}

object,

or

a

class

derived

from

{{

System.IO.Stream

}} \

(for

example,

{

Msdn

:

System.IO.FileStream

|

System.IO.FileStream

}\). {param} {exceptions} {exception:ArgumentNullException}[Open|ExcelTemplate.Open] will throw this exception if {{null}} \(C\#\) or {{Nothing}} \(VB.NET\) is passed to the method. {exception} {exception:ArgumentException} {exception} {remarks}If your template file is the new Office Open XML \(.xlsx\) format, you can pass it into the [ExcelTemplate.Open|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|ExcelTemplate.Save], as ExcelWriter cannot convert .xlsx files to .xls. {remarks} {example}{code:csharp|title=C#}

1System.IO.FileStream
).

Exceptions
Exception
ArgumentNullException
ArgumentNullException

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

Exception
ArgumentException
ArgumentException

Remarks

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.

Example
Code Block
csharp
csharp
titleC#


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

          //--- Open an Office Open XML Excel (.xlsx) file
          FileStream oFileStream = New FileStream(@"C:\Templates\Template.xlsx", FileMode.Open);
          oExcelTemplate.Open(oFileStream);
        
{code} {code:
Code Block
vb.net
|title=
vb.net
titlevb.net
}


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

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