ListObject.Sort Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Sıralama sütununu veya sütunlarını ve koleksiyonun sıralama düzenini ListObject alır.
public:
property Microsoft::Office::Interop::Excel::Sort ^ Sort { Microsoft::Office::Interop::Excel::Sort ^ get(); };
public Microsoft.Office.Interop.Excel.Sort Sort { get; }
member this.Sort : Microsoft.Office.Interop.Excel.Sort
Public ReadOnly Property Sort As Sort
Özellik Değeri
Sıralama sütununu veya sütunlarını ve koleksiyonun sıralama düzenini ListObject temsil eden bir Microsoft.Office.Interop.Excel.Sort.
Örnekler
Aşağıdaki kod örneği geçerli çalışma sayfasına bir ListObject ekler. Örnek daha sonra, bir Excel tablosuna karşılık gelen öğesini iki rastgele veri satırıyla doldurur ListObjectve sıralamanın A1:A3 sütun aralığına göre artan düzende gerçekleştirildiğini belirtir. Ardından, örnek tabloyu sıralamak için yöntemini çağırır Microsoft.Office.Interop.Excel.Sort.Apply
.
Bu örnek, belge düzeyinde özelleştirme içindir
private void SortListObject()
{
// Create ListObject control (table) and set table style
Microsoft.Office.Tools.Excel.ListObject employeeTable =
this.Controls.AddListObject(this.Range["A1"],
"employeeTable");
// Populate table with some data
Excel.Range rng;
rng = employeeTable.InsertRowRange;
((Excel.Range)rng[1]).Value2 = "bb";
((Excel.Range)rng[2]).Value2 = "b1";
Excel.ListRow row2 = employeeTable.ListRows.AddEx(
true);
rng = row2.Range;
((Excel.Range)rng[1]).Value2 = "aa";
((Excel.Range)rng[2]).Value2 = "a1";
// Set sort properties
employeeTable.Sort.SortFields.Add(this.Range["A1", "A3"],
Excel.XlSortOn.xlSortOnValues,
Excel.XlSortOrder.xlAscending);
// Sort worksheet
employeeTable.Sort.Apply();
}
Private Sub SortListObject()
' Create ListObject control (table) and set table style
Dim employeeTable As Microsoft.Office.Tools.Excel.ListObject = _
Me.Controls.AddListObject(Me.Range("A1"), "employeeTable")
' Populate table with some data
Dim rng As Excel.Range
rng = employeeTable.InsertRowRange
rng(ColumnIndex:=1).Value2 = "bb"
rng(ColumnIndex:=2).Value2 = "b1"
Dim row2 As Excel.ListRow = employeeTable.ListRows.AddEx( _
AlwaysInsert:=True)
rng = row2.Range
rng(ColumnIndex:=1).Value2 = "aa"
rng(ColumnIndex:=2).Value2 = "a1"
' Set sort properties
employeeTable.Sort.SortFields.Add(Me.Range("A1", "A3"), _
Excel.XlSortOn.xlSortOnValues, Excel.XlSortOrder.xlAscending)
' Sort worksheet
employeeTable.Sort.Apply()
End Sub