ListObject.DataBoundFormatSettings Propriedade
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Obtém ou define quais FormatSettings do XlRangeAutoFormat especificado serão aplicados ao controle ListObject.
public Microsoft.Office.Tools.Excel.FormatSettings DataBoundFormatSettings { get; set; }
Valor da propriedade
Uma combinação bit a bit dos valores FormatSettings.
Exemplos
O exemplo de código a seguir cria um DataTable e um ListObject, além de associar o ListObject ao DataTable. Em seguida, ele define o FormatSettings para aplicar ao ListObject e usa um XlRangeAutoFormat valor para fornecer o formato.
Este exemplo destina-se a uma personalização no nível de documento.
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"], "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;
}
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
Comentários
Por padrão, todas as informações no XlRangeAutoFormat estilo são aplicadas. No entanto, itens específicos podem ser removidos para que o estilo não seja aplicado a esses itens. Esses itens são:
Número
Fonte
Alinhamento
Borda
Padrão
Largura
Para aplicar apenas os estilos selecionados, defina DataBoundFormatSettings antes de a DataBoundFormat propriedade ser definida. DataBoundFormatSettingsnão funcionará se DataBoundFormat já estiver definido.