Dim myWorkbook As Infragistics.Documents.Excel.Workbook = ExcelExampleTable.CreateExampleWorkbook()
' Get a table.Table is created in separate code snippet.
Dim table As Infragistics.Documents.Excel.WorksheetTable = myWorkbook.GetTable("Patients")
Dim lastRow As Integer = table.DataAreaRegion.LastRow
Dim rand As New Random()
' Set Red background for random cells from first column
Dim i As Integer = 1
While i < lastRow
If rand.[Next](2) = 1 Then
myWorkbook.Worksheets(0).Rows(i).Cells(0).CellFormat.Fill = Infragistics.Documents.Excel.CellFill.CreateSolidFill(System.Drawing.Color.FromArgb(255, 255, 0, 0))
End If
i += 1
End While
' Create Background Color Sort Condition
Dim filterFill As Infragistics.Documents.Excel.CellFill = Infragistics.Documents.Excel.CellFill.CreateSolidFill(System.Drawing.Color.FromArgb(255, 255, 0, 0))
Dim fillSortCondition As New Infragistics.Documents.Excel.Sorting.FillSortCondition(filterFill, Infragistics.Documents.Excel.Sorting.SortDirection.Ascending)
table.Columns(0).SortCondition = fillSortCondition
myWorkbook.Save("C:\TableSorting-Sorted.xlsx")