-
Notifications
You must be signed in to change notification settings - Fork 275
Data field ShowDataAs
Mats Alm edited this page Nov 6, 2023
·
6 revisions
EPPlus from version 5.7 supports setting the ShowDataAs (Show Value As in Excel) property on pivot table data fields. ShowDataAs sets different calculation options on the data field.
EPPlus supports the follwing options:
- Difference from
- Index
- Percent of value
- Percent difference from a value
- Percent of column total,
- Percent of row total
- Percent of total
- Running total
- Percent of parent row
- Percent of parent column
- Percent of parent
- Rank ascending
- Rank descending
- Percent of running total
To set the ShowDataAs.Value
property, use the different methods prefixed Set available on 'ShowDataAs' property:
//This sets 'Show Value As' for the data field to Percent of column total
var df = pivotTable5.DataFields.Add(pivotTable5.Fields["OrderValue"]);
df.Name = "Order value % of total";
df.ShowDataAs.SetPercentOfColumn();
df.Format = "0.0%;";
Some ShowValueAs types requires you to relate to an individual item or the previous or the next item:
var rowField1 = pivotTable5.RowFields.Add(pivotTable5.Fields["CompanyName"]);
var df3 = pivotTable5.DataFields.Add(pivotTable5.Fields["OrderValue"]);
df3.Name = "Count Difference From Previous";
df3.ShowDataAs.SetDifference(rowField1, ePrevNextPivotItem.Previous);
df3.Function = DataFieldFunctions.Count;
df3.Format = "#,##0";
EPPlus Software AB - https://epplussoftware.com
- Getting Started
- The Sample Project
- EPPlus and Docker
- EPPlus and Blazor
- EPPlus and Linux
- Security
- Configuration
- Releases/versioning
- What is new in EPPlus 5+
- Breaking Changes in EPPlus 5
- Breaking Changes in EPPlus 6
- Breaking Changes in EPPlus 7
- Addressing a worksheet
- Dimension/Used range
- Copying ranges/sheets
- Insert/Delete
- Filling ranges
- Sorting ranges
- Taking and skipping columns/rows
- Data validation
- Comments
- Freeze and Split Panes
- Header and Footer
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles