Infragistics.Documents.Excel.Workbook myWorkbook = ExcelExampleTable.CreateExampleWorkbook();
// Get a table.Table is created in separate code snippet.
Infragistics.Documents.Excel.WorksheetTable table = myWorkbook.GetTable("Patients");
int lastRow = table.DataAreaRegion.LastRow;
Random rand = new Random();
// Set Red background for random cells from first column
for (int i = 1; i < lastRow; i++)
{
if (rand.Next(2) == 1)
{
myWorkbook.Worksheets[0].Rows[i].Cells[0].CellFormat.Fill = Infragistics.Documents.Excel.CellFill.CreateSolidFill(
Infragistics.Core.Graphics.Color.FromArgb(255, 255, 0, 0));
}
}
// Create Background Color Sort Condition
Infragistics.Documents.Excel.CellFill filterFill = Infragistics.Documents.Excel.CellFill.CreateSolidFill(
Infragistics.Core.Graphics.Color.FromArgb(255, 255, 0, 0));
Infragistics.Documents.Excel.Sorting.FillSortCondition fillSortCondition = new Infragistics.Documents.Excel.Sorting.FillSortCondition(
filterFill, Infragistics.Documents.Excel.Sorting.SortDirection.Ascending);
table.Columns[0].SortCondition = fillSortCondition;
myWorkbook.Save(outputStream);