다음을 통해 공유


FormatSettings 열거형

데이터에 바인딩될 때 ListObject에 적용되는 서식의 유형을 지정합니다.

이 열거형에는 멤버 값을 비트로 조합할 수 있는 FlagsAttribute 특성이 있습니다.

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

구문

‘선언
<FlagsAttribute> _
Public Enumeration FormatSettings
[FlagsAttribute]
public enum FormatSettings

멤버

멤버 이름 설명
Number 미리 정의된 XlRangeAutoFormat에 숫자 서식을 포함할지 여부를 나타냅니다.
Font 미리 정의된 XlRangeAutoFormat에 글꼴 서식을 포함할지 여부를 나타냅니다.
Alignment 미리 정의된 XlRangeAutoFormat에 맞춤을 포함할지 여부를 나타냅니다.
Border 미리 정의된 XlRangeAutoFormat에 테두리 서식을 포함할지 여부를 나타냅니다.
Pattern 미리 정의된 XlRangeAutoFormat에 패턴 서식을 포함할지 여부를 나타냅니다.
Width 미리 정의된 XlRangeAutoFormat에 열 너비 및 행 높이를 포함할지 여부를 나타냅니다.

설명

6가지 설정을 조합하여 서식을 지정할 수 있습니다. 이 열거형을 사용하여 ListObject에 적용할 설정을 선택할 수 있습니다. 기본적으로는 모든 서식 설정이 적용됩니다.

예제

다음 코드 예제에서는 DataTableListObject를 만들고 DataTableListObject를 바인딩합니다. 그런 다음 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;
}

참고 항목

참조

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