Saves a specified Workbook as a BIFF8 format (Excel 97 or later) .xls file.

public static void Save(this ExcelApplication excelApplication, Workbook workbook, Microsoft.SharePoint.SPListItem listItem, String fileName)
Public Overridable Sub Save(ByVal excelApplication As ExcelApplication, ByVal workbook As Workbook, ByVal listItem As Microsoft.SharePoint.SPListItem, ByVal fileName As String)

The current ExcelApplication object which is saving the workbook to file

A Workbook object representing the workbook to save.

SharePoint List Item to which the file is attached

Specifies a file name for the Workbook. ExcelWriter will save the file as an attachment to the List Item using this name.

If there is a problem creating, opening, or writing to the file specified, or reading from the workbook object.

This is an extension method for the ExcelApplication object to be used for saving spreadsheets to SharePoint List Items. To use this method, you must add a reference to SoftArtisans.OfficeWriter.ExcelWriter.SharePointIntegration.dll

//--- Retrieve current AllowUnsafeUpdates value
bool currentAllowUnsafeUpdates = list.ParentWeb.AllowUnsafeUpdates;

//--- You must allow unsafe updates in order for the file to be saved in the
//--- List from a web application
list.ParentWeb.AllowUnsafeUpdates = true;
xla.Save(wb, listItem, "populated.xls");

//--- Update the list
listItem.Update();

//--- Return the AllowUnsafeUpdates value to its original state
list.ParentWeb.AllowUnsafeUpdates = currentAllowUnsafeUpdates;
        
'--- Retrieve current AllowUnsafeUpdates value
Dim currentAllowUnsafeUpdates As Boolean = list.ParentWeb.AllowUnsafeUpdates

'--- You must allow unsafe updates in order for the file to be saved in the
'--- List from a web application
list.ParentWeb.AllowUnsafeUpdates = True
xla.Save(wb, listItem, "populated.xls")

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

'--- Return the AllowUnsafeUpdates value to its original state
list.ParentWeb.AllowUnsafeUpdates = currentAllowUnsafeUpdates