JanKallman / EPPlus

Create advanced Excel spreadsheets using .NET
3.76k stars 1.18k forks source link

Pivot Table support in Conditional Formatting #399

Open ptrushin opened 5 years ago

ptrushin commented 5 years ago

Do you plan to implement Pivot Table support in Conditional Formatting? With the functionality of applying rule to all cells showing as described in https://www.contextures.com/images/pivot/pivotconditionalformat07.png https://www.contextures.com/excelpivottableconditionalformat.html

It need for pivot table not losing the format after refresh.

I only find one mention of "pivot" attribute in https://github.com/JanKallman/EPPlus/blob/e7230ed0450ff9985b4c8a159f74ca1c348d6e67/EPPlus/ConditionalFormatting/CF%20Implementation.cs But not implementation.

The same problem is https://github.com/JanKallman/EPPlus/issues/141

ptrushin commented 5 years ago

Very dirty, but work for me ... public static void AddConditionalFormattingToPivotTable(ExcelPivotTable pivotTable) {
var worksheetXml = pivotTable.WorkSheet.WorksheetXml; var element = worksheetXml.GetElementsByTagName("conditionalFormatting")[0]; ((XmlElement)element).SetAttribute("pivot", "1"); }