Skip to main content

How to: Format Cell Values

The following example shows how to format Order Date field values and summaries corresponding to the Extended Price field. Order Date field values are formatted using a long date pattern while Extended Price summaries are formatted as integer currency values.

The result of the code is shown below:

AspPivot_Formatting_Example

<dx:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server" ClientIDMode="AutoID" DataSourceID="SqlDataSource1" Theme="DevEx">
    <Fields>
        <dx:PivotGridField ID="fieldExtendedPrice" Area="DataArea" FieldName="Extended_Price" 
            CellFormat-FormatType="Numeric" CellFormat-FormatString="c0">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldOrderDate" Area="RowArea" FieldName="OrderDate" GroupInterval="Date" 
            ValueFormat-FormatType="DateTime" ValueFormat-FormatString="D">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldCountry" Area="ColumnArea" FieldName="Country">
        </dx:PivotGridField>
    </Fields>
</dx:ASPxPivotGrid>