Message-ID: <942849255.9091.1711675850779.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_9090_1688961843.1711675850779" ------=_Part_9090_1688961843.1711675850779 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Generates an Excel binary or OOXML file and saves it to a SharePoint Doc= ument Library.
=20public static void Save(this ExcelTemplate template, Microsoft.SharePoint.S= PDocumentLibrary docLib, string fileName, bool overwrite)=20
Public Shared Sub Save(ByVal template As ExcelTemplate, ByVal docLib As Mic= rosoft.SharePoint.SPDocumentLibrary, ByVal fileName As String, ByVal overwr= ite As Boolean)=20
Save
will throw this exception if=20
null
(C#) or=20
Nothing
(VB.NET) is passed to the method.=20
ExcelWriter allows you to save in both the Excel 97-03 BIFF8 format (.xl= s) 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 mu= st start with a .xls template, and if you wish to output .xlsx files, you m= ust start with a .xlsx template. ExcelWriter does not support the creation = or editing of .xlsx files with the ExcelApplication object.
=20You can call Save
more than once for a single instance of <=
a href=3D"/display/EW8/ExcelTemplate" rel=3D"nofollow">ExcelTemplate. T=
his 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.
//--- Retrieve current AllowUnsafeUpdates value bool currentAllowUnsafeUpdates =3D documentLibrary.ParentWeb.AllowUnsafeUpd= ates; //--- You must allow unsafe updates in order for the file to be saved in th= e //--- Document Library from a web application documentLibrary.ParentWeb.AllowUnsafeUpdates =3D true; xlt.Save(documentLibrary, "populated.xlsx", true); //--- Update the document library documentLibrary.Update(); //--- Return the AllowUnsafeUpdates value to its original state documentLibrary.ParentWeb.AllowUnsafeUpdates =3D currentAllowUnsafeUpdates;=20
'--- Retrieve current AllowUnsafeUpdates value Dim currentAllowUnsafeUpdates As Boolean =3D documentLibrary.ParentWeb.Allo= wUnsafeUpdates '--- You must allow unsafe updates in order for the file to be saved in the '--- Document Library from a web application documentLibrary.ParentWeb.AllowUnsafeUpdates =3D True xlt.Save(documentLibrary, "populated.xlsx", True) '--- Update the document library documentLibrary.Update() '--- Return the AllowUnsafeUpdates value to its original state documentLibrary.ParentWeb.AllowUnsafeUpdates =3D currentAllowUnsafeUpdates=20