.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+
Row

PivotDataField.NumberFormat Property

Gets or sets a format string used to display summary values within the data field.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v19.2.Core.dll

Declaration

string NumberFormat { get; set; }
Property NumberFormat As String
string NumberFormat { get; set; }
Property NumberFormat As String
string NumberFormat { get; set; }
Property NumberFormat As String

Property Value

Type Description
String

A String value that specifies the number format to be applied to the data field.

Property Value

Type Description
String

A String value that specifies the number format to be applied to the data field.

Property Value

Type Description
String

A String value that specifies the number format to be applied to the data field.

Remarks

By default, when you create a PivotTable report, numbers in the data area are formatted with the General number format. To change the default number format, use the NumberFormat property. By applying a different number format, you can display numeric values in a data field as percentages, monetary values, and so on.

The following example demonstrates how to apply a number format to a data field in the PivotTable report.

Dim sourceWorksheet As Worksheet = workbook.Worksheets("Data1")
Dim worksheet As Worksheet = workbook.Worksheets.Add()
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a pivot table.
Dim pivotTable As PivotTable = worksheet.PivotTables.Add(sourceWorksheet("A1:D41"), worksheet("B2"))

' Add the "Product" field to the row axis area.
pivotTable.RowFields.Add(pivotTable.Fields("Product"))
' Add the "Category" field to the column axis area.
pivotTable.ColumnFields.Add(pivotTable.Fields("Category"))
' Add the "Sales" field to the data area and specify the custom field name.
Dim dataField As PivotDataField = pivotTable.DataFields.Add(pivotTable.Fields("Sales"), "Sales(Sum)")
' Specify the number format for the "Sales" field.
dataField.NumberFormat = "_([$$-409]* #,##0.00_);_([$$-409]* (#,##0.00);_([$$-409]* "" - ""??_);_(@_)"
' Add the "Region" field to the filter area.
pivotTable.PageFields.Add(pivotTable.Fields("Region"))
See Also