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

SharePointIntegration.Save(ExcelApplication, Workbook, Microsoft.Sh= arePoint.SPListItem, String)

Introduced in build 7.1.0.1855

=20

Description

=20

Saves a specified Workbook as a BI= FF8 format (Excel 97 or later) .xls file.

=20
C#
=20
public static void Save(this ExcelApplication excelApplication, Workbook wo=
rkbook, Microsoft.SharePoint.SPListItem listItem, String fileName)
=20
=20
vb.net
=20
Public Overridable Sub Save(ByVal excelApplication As ExcelApplication, ByV=
al workbook As Workbook, ByVal listItem As Microsoft.SharePoint.SPListItem,=
 ByVal fileName As String)
=20
=20

Parameters

=20
excelApplication
The cur= rent ExcelApplication object which is saving the workbook to file=20
workbook
A=20 Workbook object representing the workbook to save.=20
listItem
SharePoint List Item to= which the file is attached=20
fileName
Specifies a file name f= or the Workbook. ExcelWriter will save the file as an attachment to the Lis= t Item using this name.=20

Exceptions

=20
System.Exception
If ther= e is a problem creating, opening, or writing to the file specified, or read= ing from the workbook object.=20

Remarks

=20
=20 Icon=20
=20

This is an extension method for the ExcelApplication object to be used f= or saving spreadsheets to SharePoint List Items. To use this method, you mu= st add a reference to SoftArtisans.OfficeWriter.ExcelWriter.SharePointInteg= ration.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;
xla.Save(wb, listItem, "populated.xls");

//--- 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
xla.Save(wb, listItem, "populated.xls")

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

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