Infragistics.Excel–Set the format to dollars on a cell, column or row.


These extension methods will allow you to easily format a column for dollars. These can be altered to use any format that you can create in Excel (and then copy and paste here). I do this a lot when creating spreadsheets and these save me time trying to remember the impossible to remember FormatString.

''' <summary>
''' Formats the specified cell as dollars.
''' </summary>
''' <param name="cell"></param>
<Extension()> _
Public Sub SetFormatDollars(ByVal cell As WorksheetCell)
    cell.CellFormat.FormatString = """$""#,##0.00_);(""$""#,##0.00)"
End Sub

''' <summary>
''' Formats the specified column as dollars.
''' </summary>
''' <param name="column"></param>
<Extension()> _
Public Sub SetFormatDollars(ByVal column As WorksheetColumn)
    column.CellFormat.FormatString = """$""#,##0.00_);(""$""#,##0.00)"
End Sub

''' <summary>
''' Formats the specified row as dollars.
''' </summary>
''' <param name="row"></param>
<Extension()> _
Public Sub SetFormatDollars(ByVal row As WorksheetRow)
    row.CellFormat.FormatString = """$""#,##0.00_);(""$""#,##0.00)"
End Sub

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.