-
Notifications
You must be signed in to change notification settings - Fork 297
Pivot table styling via Pivot Areas
Jan Källman edited this page Mar 8, 2021
·
12 revisions
Pivot tables can be styled with using special conditions rather than styling via the A1C1 notation. EPPlus from version 5.6 supports this custom styling.
A pivot area defines an area within the pivot table. This example adds a style for the whole table and sets the font to Times New Roman and the font color to Accent2.
var styleWholeTable = pivotTable1.Styles.AddWholeTable();
styleWholeTable.Style.Font.Name = "Times New Roman";
styleWholeTable.Style.Font.Color.SetColor(eThemeSchemeColor.Accent2);You can also specify a specific style for all Labels...
var styleLabels = pivot1.Styles.AddAllLabels();
styleLabels.Style.Font.Color.SetColor(eThemeSchemeColor.Accent4);
styleLabels.Style.Font.Italic = true;...or all data
var styleData = pivot1.Styles.AddAllData();
styleData.Style.Font.Name = "Arial";
styleLabels.Style.Font.Bold = true;You can also add styles for other parts of the pivot table like the button fields, top left and right area.
//Styles the area to the left of the column axis button field.
var topLeft = pivot2.Styles.AddTopStart();
topLeft.Style.Fill.BackgroundColor.SetColor(Color.Green);
//Styles the area to the right of the the column axis button field label.
var topRight = pivot2.Styles.AddTopEnd();
topRight.Style.Fill.BackgroundColor.SetColor(Color.Red);
//Here we only want to style a part of the top right area.
//We use the Offset property that uses the A1C1 address notation starting from the cell to the right as A1.
//B1 here will be the second cell to the right. You can also use multiple cells references, like A1:B1
var topRightOffset1 = pivot2.Styles.AddTopEnd("B1");
topRightOffset1.Style.Border.BorderAround(ExcelBorderStyle.Dotted, eThemeSchemeColor.Text1);EPPlus Software AB - https://epplussoftware.com
- What is new in EPPlus 5+
- Breaking Changes in EPPlus 5
- Breaking Changes in EPPlus 6
- Breaking Changes in EPPlus 7
- Breaking Changes in EPPlus 8
- 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
- Hyperlinks
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- The ExcelRange.Text property
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles