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 SharePointIntegration.Save(ExcelTemplate, Microsoft.SharePoint.S= PDocumentLibrary, String, Boolean)

SharePointIntegration.Save(ExcelTemplate, Microsoft.SharePoint.SPDo= cumentLibrary, String, Boolean)

Introduced in build 7.1.0.1855

=20

Description

=20

Generates an Excel binary or OOXML file and saves it to a SharePoint Doc= ument Library.

=20
C#
=20
public static void Save(this ExcelTemplate template, Microsoft.SharePoint.S=
PDocumentLibrary docLib, string fileName, bool overwrite)
=20
=20
vb.net
=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
=20

Parameters

=20
template
The current ExcelTem= plate object which is being saved.=20
docLib
SharePoint Document Libr= ary that contains the Excel spreadsheet being opened=20
fileName
Name of the output f= ile. ExcelWriter will save the file to the document library using this name= . If a file with the same name exists, it will be overwritten by the new Ex= cel file if the overwrite parameter is set to True.=20
overwrite
Set to True to ove= rwrite an Excel file if one already exists by that name in the Document Lib= rary=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
ArgumentException
=20

Remarks

=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.

=20

You 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.

=20
=20 Icon=20
=20

This is an extension method for the ExcelTemplate object to be used for = saving spreadsheets to SharePoint Document Libraries. To use this method, y= ou must add a reference to SoftArtisans.OfficeWriter.ExcelWriter.SharePoint= Integration.dll

=20
=20
=20

Examples

=20
C#
=20
//--- 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
=20
vb.net
=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
------=_Part_9090_1688961843.1711675850779--