ListObject.Publish Method (Object, Boolean)

 

Publishes the ListObject control to a server that is running Microsoft Windows SharePoint Services.

Namespace:   Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

string Publish(
	object Target,
	bool LinkSource
)

Parameters

Target
Type: System.Object

Contains an array of strings. The following table describes the elements of this array.

[1|1] Element#

[1|2] Contents

[2|1] 0

[2|2] URL of SharePoint server.

[3|1] 1

[3|2] ListName (Display Name).

[4|1] 2

[4|2] Description of the list.

LinkSource
Type: System.Boolean

Boolean. (See Remarks section.)

Return Value

Type: System.String

The URL of the published list on the SharePoint site.

If the ListObject control is not currently linked to a list on a SharePoint site, setting LinkSource to true will create a new list on the specified SharePoint site. If the ListObject control is currently linked to a SharePoint site, setting the LinkSource argument to true will replace the existing link (you can only link the list to one SharePoint site). If the ListObject control is not currently linked, setting LinkSource to false will leave the ListObject control unlinked. If the ListObject control is currently linked to a SharePoint site, setting LinkSource to false will keep the ListObject control linked to the current SharePoint site.

The following code example creates a ListObject on the current worksheet and then calls the Publish method to publish the ListObject to a Web site that is running Microsoft Windows SharePoint Services. This example assumes that the SharePointURL parameter identifies a valid URL to a Web site running Microsoft Windows SharePoint Services.

This example is for a document-level customization.

private void ListObject_Publish(string SharePointURL)
{
    Microsoft.Office.Tools.Excel.ListObject list1 =
        this.Controls.AddListObject(this.Range["A1", "D4"], "Employees");

    // Publish the list object to the SharePoint URL.
    object[] TargetParam = { SharePointURL, "Employees", "Employee data" };
    list1.Publish(TargetParam, false);
}
Return to top
Show: