Skip to content

Commit

Permalink
Fixed small issue with slicer fields on pivot tables
Browse files Browse the repository at this point in the history
  • Loading branch information
JanKallman committed Nov 15, 2024
1 parent 529e205 commit a292d83
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/EPPlus/Drawing/Slicer/ExcelPivotTableSlicerCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal void Init(ExcelWorkbook wb, string name, ExcelPivotTableField field)
PivotTables.Add(_field.PivotTable);
CreateWorkbookReference(wb, ExtLstUris.WorkbookSlicerPivotTableUri);
SlicerCacheXml.Save(Part.GetStream());
Data.Items.Refresh();
Data.Items.Refresh();
}
/// <summary>
/// Init must be called before accessing any properties as it sets several properties.
Expand Down
21 changes: 14 additions & 7 deletions src/EPPlus/Table/PivotTable/ExcelPivotTableCacheField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -885,16 +885,18 @@ internal void Refresh()
private void UpdateGroupItems()
{
foreach (var pt in _cache._pivotTables)
{
if ((pt.Fields[Index].IsRowField ||
pt.Fields[Index].IsColumnField ||
pt.Fields[Index].IsPageField || pt.Fields[Index].Cache.HasSlicer) )
{
var fld = pt.Fields[Index];
if ((fld.IsRowField ||
fld.IsColumnField ||
fld.IsPageField || fld.Cache.HasSlicer) )
{
pt.Fields[Index].UpdateGroupItems(this, true);
fld.UpdateGroupItems(this, true);
fld.Items.MatchValueToIndex();
}
else
{
pt.Fields[Index].DeleteNode("d:items");
fld.DeleteNode("d:items");
}
}
}
Expand Down Expand Up @@ -941,7 +943,12 @@ private void UpdateSharedItems()
{
UpdateSlicers();
}
}
//Match items in pivot tables.
foreach (var pt in _cache._pivotTables)
{
pt.Fields[Index].Items.MatchValueToIndex();
}
}

private void UpdatePivotItemsFromSharedItems(HashSet<object> siHs)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public void SelectSingleItem(int index)
public void Refresh()
{
_field.Cache.Refresh();
MatchValueToIndex();
_hiddenItemIndex = null;
}

Expand Down

0 comments on commit a292d83

Please sign in to comment.