Class PivotCalculatedFields
Represents collection of calculated fields in the pivot table.
Inheritance
System.Object
PivotCalculatedFields
Implements
Namespace: Syncfusion.XlsIO.Implementation.PivotTables
Assembly: Syncfusion.XlsIO.Base.dll
Syntax
public class PivotCalculatedFields : List<PivotFieldImpl>, IPivotCalculatedFields
Constructors
PivotCalculatedFields(PivotTableImpl)
Initializes a new instance of pivot calculated fields collection with the specified pivot table.
Declaration
public PivotCalculatedFields(PivotTableImpl pivotTable)
Parameters
Type | Name | Description |
---|---|---|
PivotTableImpl | pivotTable | Pivot table from which the calculated fields are extracted. |
Properties
Item[Int32]
Gets a pivot field with the specified index from the collection. Read-only.
Declaration
public IPivotField this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Zero-based index of the item to get. |
Property Value
Type |
---|
IPivotField |
Explicit Interface Implementations
IPivotCalculatedFields.Add(String, String)
Adds calculated field to the pivot table based on the specified formula.
Declaration
IPivotField IPivotCalculatedFields.Add(string name, string formula)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Represents the name of the calculated pivot field. |
System.String | formula | Represents the formula of the calculated pivot field. |
Returns
Type | Description |
---|---|
IPivotField | Returns the calculated pivot field. |
Examples
Following code snippet illustrates how to add a pivot calculated field to the pivot table.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
// Create Pivot cache with the given data range
IPivotCache cache = workbook.PivotCaches.Add(worksheet["A1:H50"]);
//Create "PivotTable1" with the cache at the specified range
IPivotTable pivotTable = worksheet.PivotTables.Add("PivotTable1", worksheet["A1"], cache);
//Add Pivot table fields (Row and Column fields)
pivotTable.Fields[2].Axis = PivotAxisTypes.Row;
pivotTable.Fields[6].Axis = PivotAxisTypes.Row;
pivotTable.Fields[3].Axis = PivotAxisTypes.Column;
//Add data field
IPivotField field = pivotTable.Fields[5];
pivotTable.DataFields.Add(field, "Sum", PivotSubtotalTypes.Sum);
IPivotCalculatedFields.get_Item(String)
Declaration
IPivotField IPivotCalculatedFields.get_Item(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name |
Returns
Type |
---|
IPivotField |
IPivotCalculatedFields.Item[String]
Gets a pivot field with the specified name from the collection. Read-only.
Declaration
IPivotField IPivotCalculatedFields.this[] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Calculated Field Name |
Returns
Type |
---|
IPivotField |