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

Saves the generated Excel file on the server. The ASPNET account (IIS5), NETWORK SERVICE account (IIS6 or IIS7), or the authenticated user must have Write access to the destination directory specified by the outputFileName parameter.

Signature
C#
C#
 public virtual void Save(System.String fileName)
{signature}
{signature:
}
Signature
vb.net
vb.net
Public Overridable Sub Save(ByVal fileName As String)
{signature}
{parameters}
{param:outputFileName}Specifies a complete path and file name for the generated file. ExcelWriter will save the file to this location. If a file with the same name exists, it will be overwritten by the new Excel file.
{param}
{exceptions}
{exception:ArgumentNullException}{{Save}} will throw this exception if {{null}} \(C\#\) or {{Nothing}} \(VB.NET\) is passed to the method.
{exception}
{exception:ArgumentException}
{exception}
{remarks}ExcelWriter allows you to save in both the Excel 97\-03 BIFF8 format \(.xls\) or the new Office Open XML \(.xlsx\) format.  The template file must be of the expected output format. Hence, if you wish to output .xls files, you must start with a .xls template, and if you wish to output .xlsx files, you must start with a .xlsx template.  ExcelWriter does not support the creation or editing of .xlsx files with the [ExcelApplication|ExcelApplication] object.

You can call [Save|ExcelTemplate.Save] more than once for a single instance of [ExcelTemplate]. This allows you to save more than one copy of a generated file, and/or both save the file on the server and stream it to the client. 

{remarks}
{example}{code:csharp|title=C#}
Parameters
Param
outputFileName
outputFileName

Specifies a complete path and file name for the generated file. ExcelWriter will save the file to this location. If a file with the same name exists, it will be overwritten by the new Excel file.

Exceptions
Exception
ArgumentNullException
ArgumentNullException

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

Exception
ArgumentException
ArgumentException

Remarks

ExcelWriter allows you to save in both the Excel 97-03 BIFF8 format (.xls) or the new Office Open XML (.xlsx) format. The template file must be of the expected output format. Hence, if you wish to output .xls files, you must start with a .xls template, and if you wish to output .xlsx files, you must start with a .xlsx template. ExcelWriter does not support the creation or editing of .xlsx files with the ExcelApplication object.

You can call Save more than once for a single instance of ExcelTemplate. This allows you to save more than one copy of a generated file, and/or both save the file on the server and stream it to the client.

Example
Code Block
csharp
csharp
titleC#


          //--- Save a .xls file
          xlTemplate.Save(@"C:\Reports\Orders.xls");

          //--- Save a .xlsx file
          xlTemplate.Save(@"C:\Reports\Orders.xlsx");
        
{code} {code:
Code Block
vb.net
|title=
vb.net
titlevb.net
}


          '--- Save a .xls file
          xlTemplate.Save("c:\Reports\Orders.xls")

          '--- Save a .xlsx file
          xlTemplate.Save("c:\Reports\Orders.xlsx")
        
{code} {example}