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
Saves the generated Word file to a SharePoint List Item.
=20public static void Save(this WordTemplate template, Microsoft.SharePoint.Li= stItem listItem, string fileName)=20
Public Shared Sub Save(ByVal template As WordTemplate, ByVal listItem As Mi= crosoft.SharePoint.ListItem, ByVal fileName As String)=20
Save
will throw this exception if=20
null
(C#) or=20
Nothing
(VB.NET) is passed to the method.=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 =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
'--- 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