Skip to main content
A newer version of this page is available. .
Row

PivotTable.ColumnFields Property

Provides access to the collection of fields located in the column axis area of the PivotTable report.

Namespace: DevExpress.Spreadsheet

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

Declaration

PivotFieldReferenceCollection ColumnFields { get; }

Property Value

Type Description
PivotFieldReferenceCollection

A PivotFieldReferenceCollection object that represents the collection of column fields.

Remarks

Use the ColumnFields property to get access to the collection that stores all column fields added to the PivotTable report. An individual column field can be accessed by its index or name in the collection.

To add a new column field to the pivot table, use the PivotFieldReferenceCollection.Add method. To add a field to the column area at the specified position, use the PivotFieldReferenceCollection.Insert method.

To remove a column field from the PivotTable report, use the PivotFieldReferenceCollection.Remove or PivotFieldReferenceCollection.RemoveAt method. You can also use the PivotFieldReferenceCollection.Clear method to remove all fields from the PivotTable’s column area at once.

Example

Worksheet sourceWorksheet = workbook.Worksheets["Data1"];
Worksheet worksheet = workbook.Worksheets.Add();
workbook.Worksheets.ActiveWorksheet = worksheet;

// Create a pivot table.
PivotTable 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.
PivotDataField dataField = 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"]);

The following code snippets (auto-collected from DevExpress Examples) contain references to the ColumnFields 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