worksheet1.Columns(2).CellFormat.FormatString = """$""#,##0.00;[red](""$""#,##0.00)"
The Infragistics Excel Engine allows you to customize the look and behavior of a cell. You can customize a cell by setting properties exposed by the CellFormat property of the WorksheetCell, WorksheetRow, WorksheetColumn, or WorksheetMergedCellsRegion objects.
You can customize every aspect of a cell’s appearance. You can set a cell’s font, background, and borders, as well as text alignment and rotation. You can even apply a different format on a character-by-character basis for a cell’s text.
You can also format cell values by assigning a format string. An acceptable format string follows the .NET standard format and formatting codes.
The following code shows you how to format a cell to display numbers as currency and to color negative values red. The example code assumes you have a reference to a Worksheet named worksheet1.
In Visual Basic:
worksheet1.Columns(2).CellFormat.FormatString = """$""#,##0.00;[red](""$""#,##0.00)"
In C#:
worksheet1.Columns[2].CellFormat.FormatString = "\"$\"#,##0.00;[red](\"$\"#,##0.00)";