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

Streams the specified workbook to the client. It should be the only method that uses the response object, as it automatically sets response headers, clears the body of the response, and flushes it to the client.

Signature
C#
C#
 public virtual void Save(Workbook workbook, System.Web.HttpResponse response, System.String fileName, boolean openInBrowser, System.String contentType)
{signature}{signature:
}
Signature
vb.net
vb.net
Public Overridable Sub Save(ByVal workbook As Workbook, ByVal response As System.Web.HttpResponse, ByVal fileName As String, ByVal openInBrowser As Boolean, ByVal contentType As String)
{signature}
{parameters}
{param:workbook}A [Workbook|Workbook] object representing the workbook to save.{param}
{param:response}A {msdn:
Parameters
Param
workbook
workbook

A Workbook object representing the workbook to save.

Param
response
response

A

Msdn
System.Http.Response

|

System.Http.Response

}

1System.Http.Response
object,

usually

[

Page.Response

|Page.Response].{param} {param:fileName}Specifies a file name for the workbook. This name will be displayed in the download dialog when the file is streamed to the browser.{param} {param:openInBrowser}If true, the spreadsheet will be opened in place in Internet Explorer, rather than spawning a seperate Excel window.{param} {param:contentType}The content\-type header sent to the browser with the generated spreadsheet.{param} {exceptions} {exception:System.Exception}If there is an error obtaining the response stream from the Response object.{exception} {exception:System.ArgumentException}If the extension of the filename given is invalid for the given workbook. For example, a file created with Excel 2007, that has macros must be saved with the .xlsm extension. If the content type is invalid given is invalid for the given workbook.{exception} {example}{code:csharp|title=C#}

.

Param
fileName
fileName

Specifies a file name for the workbook. This name will be displayed in the download dialog when the file is streamed to the browser.

Param
openInBrowser
openInBrowser

If true, the spreadsheet will be opened in place in Internet Explorer, rather than spawning a seperate Excel window.

Param
contentType
contentType

The content-type header sent to the browser with the generated spreadsheet.

Exceptions
Exception
System.Exception
System.Exception

If there is an error obtaining the response stream from the Response object.

Exception
System.ArgumentException
System.ArgumentException

If the extension of the filename given is invalid for the given workbook. For example, a file created with Excel 2007, that has macros must be saved with the .xlsm extension.
If the content type is invalid given is invalid for the given workbook.

Example
Code Block
csharp
csharp
titleC#


          ExcelApplication xla = new ExcelApplication();
          Workbook wb = oExcelApp.Create();

          //--- Do something here
          xla.Save(wb, Page.Response, "generated.xls", false, "application/unknown");
        
{code} {code:
Code Block
vb.net
|title=
vb.net
titlevb.net
}


          Dim xla As New ExcelApplication()
          Dim wb As Workbook = xla.Create()

          '--- Do something here
          xla.Save(wb, Page.Response, "generated.xls", False, "application/unknown")
        
{code} {example}