Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Description

Excerpt

If you pass save an HttpServletResponse object, WordWriter will stream the generated file to the client. This method allows you to specify a default client-side file name, and whether the file should be opened in the browser window or in Microsoft Word.

Signature
C#C#
Wiki Markup
{description}
{excerpt}If you pass {{save}} an HttpServletResponse object, WordWriter will stream the generated file to the client. This method allows you to specify a default client\-side file name, and whether the file should be opened in the browser window or in Microsoft Word.{excerpt}
{signature:C#}
 public void Save(System.Web.HttpResponse response, System.String attachmentName, boolean openInBrowser)
Signature
{signature}{signature:vb.net
vb.net
}
Public Sub Save(ByVal response As System.Web.HttpResponse, ByVal attachmentName As String, ByVal openInBrowser As Boolean)
Parameters
{signature}
{parameters}
{param:response}The {msdn:System.Web.HttpResponse
instance of the page.
Param
responseresponseThe
Msdn
System.Web.HttpResponse
1HttpResponse
Param
attachmentNameattachmentName

Specifies a name for the generated Word file; this name will be displayed in the download dialog when the file is streamed to the browser.

Param
openInBrowseropenInBrowser

If openInBrowser is set to true, and the user chooses to open the file, the file will open in the browser window. If openInBrowser is set to false, and the user chooses to open the file, the file will open in Microsoft Word. By default, the file will open in the browser window.

Note

Not all browsers can embed a Word file in the browser window.

Exceptions

...

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

Remarks

You can call Save more than once for a single instance of WordTemplate. 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.

|HttpResponse} instance of the page.{param}
{param:attachmentName}Specifies a name for the generated Word file; this name will be displayed in the download dialog when the file is streamed to the browser.{param}
{param:openInBrowser}If {{openInBrowser}} is set to {{true}}, and the user chooses to open the file, the file will open in the browser window. If {{openInBrowser}} is set to {{false}}, and the user chooses to open the file, the file will open in Microsoft Word. By default, the file will open in the browser window. 
{note}Not all browsers can embed a Word file in the browser window.{note}{param}
{exceptions}
{exception:ArgumentNullException}{{Save}} will throw this exception if {{null}} \(C\#\) or {{Nothing}} \(VB.NET\) is passed to the method.{exception}
{remarks}You can call [Save|WordTemplate.Save] more than once for a single instance of [WordTemplate]. 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}
h6. Stream to the client and open in MS Word
When you pass an HttpResponse object to {{Save}}, WordWriter will stream the generated Word file to the client. The browser will display a File Download dialog asking the user to open or save the file. The method's second parameter specifies a file name to display in the File Download dialog. If the method's third parameter \- [OpenInBrowser|#param-openInBrowser] \- is False and the user chooses to open the Word file, the file will open in Microsoft Word. 
{code:csharp|title=C#}
oWW.Save(Page.Response, "StringVarOutput.doc", false);
{code}
{code:vb.net
|title=vb.net
}
oWW.Save(Page.Response, "StringVarOutput.doc", False)
Stream to the client and open in the browser window

When you pass an HttpResponse object to Save, WordWriter will stream the generated Word file to the client. The browser will display a File Download dialog asking the user to open or save the file. The method's second parameter specifies a file name to display in the File Download dialog. If the method's third parameter - OpenInBrowser - is True and the user chooses to open the Word file, the file will open in the browser window.

{code}
h6. Stream to the client and open in the browser window
When you pass an HttpResponse object to {{Save}}, WordWriter will stream the generated Word file to the client. The browser will display a File Download dialog asking the user to open or save the file. The method's second parameter specifies a file name to display in the File Download dialog. If the method's third parameter \- {{OpenInBrowser}} \- is True and the user chooses to open the Word file, the file will open in the browser window.
{code:csharp|title=C#}
            oWW.Save(Page.Response, "StringVarOutput.doc", true);
{code}
{code:vb.net
|title=vb.net
}
            oWW.Save(Page.Response, "StringVarOutput.doc", True)
{code}

{example}
Example
Stream to the client and open in MS Word

When you pass an HttpResponse object to Save, WordWriter will stream the generated Word file to the client. The browser will display a File Download dialog asking the user to open or save the file. The method's second parameter specifies a file name to display in the File Download dialog. If the method's third parameter - OpenInBrowser - is False and the user chooses to open the Word file, the file will open in Microsoft Word.

Code Block
csharpcsharp
titleC#
Code Block
vb.nettitle
Code Block
csharpcsharp
titleC#
Code Block
vb.nettitle