Skip to main content

NumberFormatOptions.FormatCode Property

Specifies a number format (in the invariant culture) used to display numeric values in chart elements.

Namespace: DevExpress.Spreadsheet.Charts

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

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

string FormatCode { get; set; }

Property Value

Type Description
String

The number format to apply to chart elements.

Property Paths

You can access this nested property as listed below:

Object Type Path to FormatCode
Axis
.NumberFormat .FormatCode
DataLabelBase
.NumberFormat .FormatCode
TrendlineLabel
.NumberFormat .FormatCode

Remarks

The Spreadsheet allows you to use Microsoft Excel number formats to display numeric values on a chart as currency, percentages, decimals, and so on.

Use the FormatCode option to specify a number format in the invariant culture. Disable the NumberFormatOptions.IsSourceLinked property to indicate that the applied format differs from the number format of the source cells.

You can also use the FormatCodeLocal property to obtain or specify a number format based on the current (local) culture defined by the DocumentOptions.Culture property.

Example

The following example demonstrates how to create a clustered column chart and display numbers on the value axis as percentage values. To apply a number format, set the NumberFormatOptions.IsSourceLinked property to false and assign the required format code to the NumberFormatOptions.FormatCode property.

View Example

Worksheet worksheet = workbook.Worksheets["chartTask3"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet["B3:C5"]);
chart.TopLeftCell = worksheet.Cells["H2"];
chart.BottomRightCell = worksheet.Cells["N14"];

// Apply a number format to axis labels.
Axis axis = chart.PrimaryAxes[1];
axis.NumberFormat.FormatCode = "0%";
axis.NumberFormat.IsSourceLinked = false;

// Hide the legend.
chart.Legend.Visible = false;

The following code snippets (auto-collected from DevExpress Examples) contain references to the FormatCode property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also