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

SharePointIntegration.Save(ExcelTemplate, Microsoft.SharePoint.SPLi= stItem, String)

Introduced in build 7.1.0.1855

=20

Description

=20

Generates an Excel binary or OOXML file and saves it as an attachment to= a SharePoint list item.

=20
C#
=20
public static void Save(this ExcelTemplate template, Microsoft.SharePoint.S=
PListItem listItem, string fileName)
=20
=20
vb.net
=20
Public Shared Sub Save(ByVal template As ExcelTemplate, ByVal listItem As M=
icrosoft.SharePoint.SPListItem, ByVal fileName As String)
=20
=20

Parameters

=20
template
The current ExcelTemplate object wh= ich is being saved.=20
listItem
SharePoint List Item to which the f= ile is attached=20
fileName
Name of the output file. ExcelWrite= r will save the file to the list item using this name.=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 List Items. To use this method, you must = add a reference to SoftArtisans.OfficeWriter.ExcelWriter.SharePointIntegrat= ion.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;
xlt.Save(listItem, "populated.xlsx");

//--- 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
xlt.Save(listItem, "populated.xlsx")

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

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