Message-ID: <854971625.8145.1711634122218.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_8144_412758205.1711634122218" ------=_Part_8144_412758205.1711634122218 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html SharePointIntegration.Save(WordTemplate, Microsoft.SharePoint.SP= ListItem, String)

SharePointIntegration.Save(WordTemplate, Microsoft.SharePoint.SPLis= tItem, String)

Introduced in build 4.1.0.1379

=20

Description

=20

Saves the generated Word file to a SharePoint List Item.

=20
C#
=20
public static void Save(this WordTemplate template, Microsoft.SharePoint.Li=
stItem listItem, string fileName)
=20
=20
vb.net
=20
Public Shared Sub Save(ByVal template As WordTemplate, ByVal listItem As Mi=
crosoft.SharePoint.ListItem, ByVal fileName As String)
=20
=20

Parameters

=20
template
The current WordTemplate object that= is being saved to file=20
listItem
SharePoint List Item to which the fi= le is being saved=20
fileName
Name of the file to be saved=20

Exceptions

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

Remarks

=20

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

=20
=20 Icon=20
=20

This is an extension method for the WordTemplate object to be used for s= aving documents to a SharePoint List Item from within SharePoint. To use th= is method, you must add a reference to SoftArtisans.OfficeWriter.WordWriter= .SharePointIntegration.dll

=20
=20
=20

Examples

=20
C#
=20
//--- Retrieve current AllowUnsafeUpdates value
bool currentAllowUnsafeUpdates =3D list.ParentWeb.AllowUnsafeUpdates;

//--- You must allow unsafe updates in order for the file to be saved in th=
e
//--- List from a web application
list.ParentWeb.AllowUnsafeUpdates =3D true;
wt.Save(listItem, "populated.docx");

//--- Update the list
listItem.Update();

//--- Return the AllowUnsafeUpdates value to its original state
list.ParentWeb.AllowUnsafeUpdates =3D currentAllowUnsafeUpdates;
        
=20
=20
vb.net
=20
'--- Retrieve current AllowUnsafeUpdates value
Dim currentAllowUnsafeUpdates As Boolean =3D list.ParentWeb.AllowUnsafeUpda=
tes

'--- You must allow unsafe updates in order for the file to be saved in the
'--- List from a web application
list.ParentWeb.AllowUnsafeUpdates =3D True
wt.Save(listItem, "populated.docx")

'--- Update the list
listItem.Update()

'--- Return the AllowUnsafeUpdates value to its original state
list.ParentWeb.AllowUnsafeUpdates =3D currentAllowUnsafeUpdates
        
=20
------=_Part_8144_412758205.1711634122218--