Поделиться через


ListObject.Publish Method

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)

Syntax

'Declaration
Function Publish ( _
    Target As Object, _
    LinkSource As Boolean _
) As String
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.

Return Value

Type: System.String
The URL of the published list on the SharePoint site.

Remarks

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.

Examples

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 Sub ListObject_Publish(ByVal SharePointURL As String)
        Dim List1 As Microsoft.Office.Tools.Excel.ListObject = _
            Me.Controls.AddListObject(Me.Range("A1", "D4"), _
            "Employees")

        ' Publish the list object to the SharePoint URL.
        Dim TargetParam() As Object = {SharePointURL, _
            "Employees", "Employee data"}
        List1.Publish(TargetParam, False)

    End Sub

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);
}

.NET Framework Security

See Also

Reference

ListObject Interface

Microsoft.Office.Tools.Excel Namespace