다음을 통해 공유


ListObject.DataBoundFormatSettings 속성

지정된 XlRangeAutoFormatListObject 컨트롤에 적용되는 FormatSettings를 가져오거나 설정합니다.

네임스페이스:  Microsoft.Office.Tools.Excel
어셈블리:  Microsoft.Office.Tools.Excel(Microsoft.Office.Tools.Excel.dll)

구문

‘선언
Property DataBoundFormatSettings As FormatSettings
    Get
    Set
FormatSettings DataBoundFormatSettings { get; set; }

속성 값

형식: Microsoft.Office.Tools.Excel.FormatSettings
FormatSettings 값의 비트 조합입니다.

설명

기본적으로 XlRangeAutoFormat 스타일의 모든 정보가 적용됩니다. 그러나 특정 항목에 스타일이 적용되지 않도록 해당 항목을 제거할 수 있습니다. 해당하는 항목은 다음과 같습니다.

  • 숫자

  • 글꼴

  • 맞춤

  • 테두리

  • 패턴

  • Width

선택한 스타일만 적용하려면 DataBoundFormat 속성을 설정하기 전에 DataBoundFormatSettings를 설정합니다. DataBoundFormatSettings는 DataBoundFormat이 이미 설정된 경우에는 작동하지 않습니다.

예제

다음 코드 예제에서는 DataTableListObject를 만들고 DataTableListObject를 바인딩합니다. 그런 다음 FormatSettings를 설정하여 ListObject에 적용하고 XlRangeAutoFormat 값을 사용하여 서식을 제공합니다.

이 예제는 문서 수준 사용자 지정을 위한 것입니다.

    Private Sub ListObject_DataBoundFormatSettings()
        ' Create a new DataSet and DataTable.
        Dim ds As New DataSet()
        Dim dt As DataTable = ds.Tables.Add("Customers")
        dt.Columns.Add(New DataColumn("LastName"))
        dt.Columns.Add(New DataColumn("FirstName"))

        ' Add a new row to the DataTable.
        Dim dr As DataRow = dt.NewRow()
        dr("LastName") = "Chan"
        dr("FirstName") = "Gareth"
        dt.Rows.Add(dr)

        ' Create a list object.
        Dim List1 As Microsoft.Office.Tools.Excel.ListObject = _
            Me.Controls.AddListObject(Me.Range( _
            "A1"), "List1")

        ' Bind the list object to the DataTable.
        List1.AutoSetDataBoundColumnHeaders = True
        List1.SetDataBinding(ds, "Customers", _
            "LastName", "FirstName")

        ' Specify the format settings that you want to include.
        ' In this example, only the Font and Pattern 
        ' settings are applied.
        List1.DataBoundFormatSettings = _
            Microsoft.Office.Tools.Excel.FormatSettings.Font Or _
            Microsoft.Office.Tools.Excel.FormatSettings.Pattern

        ' Add a format to the list object.
        List1.DataBoundFormat = _
            Excel.XlRangeAutoFormat.xlRangeAutoFormatList2

    End Sub

private void ListObject_DataBoundFormatSettings()
{
    // Create a new DataSet and DataTable.
    DataSet ds = new DataSet();
    DataTable dt = ds.Tables.Add("Customers");
    dt.Columns.Add(new DataColumn("LastName"));
    dt.Columns.Add(new DataColumn("FirstName"));

    // Add a new row to the DataTable.
    DataRow dr = dt.NewRow();
    dr["LastName"] = "Chan";
    dr["FirstName"] = "Gareth";
    dt.Rows.Add(dr);

    // Create a list object.
    Microsoft.Office.Tools.Excel.ListObject list1 = 
        this.Controls.AddListObject(
        this.Range["A1", missing], "list1");

    // Bind the list object to the DataTable.
    list1.AutoSetDataBoundColumnHeaders = true;
    list1.SetDataBinding(ds, "Customers", "LastName",
        "FirstName");

    // Specify the format settings that you want to include.
    // In this example, only the Font and Pattern 
    // settings are applied.
    list1.DataBoundFormatSettings =
        Microsoft.Office.Tools.Excel.FormatSettings.Font |
        Microsoft.Office.Tools.Excel.FormatSettings.Pattern;

    // Add a format to the list object.
    list1.DataBoundFormat = 
        Excel.XlRangeAutoFormat.xlRangeAutoFormatList2;
}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

ListObject 인터페이스

Microsoft.Office.Tools.Excel 네임스페이스