@@ -937,6 +937,7 @@ private void UpdateSharedItems()
937
937
{
938
938
UpdatePivotItemsFromSharedItems ( siHs ) ;
939
939
}
940
+
940
941
SharedItems . _list = siHs . ToList ( ) ;
941
942
UpdateCacheLookupFromItems ( SharedItems . _list , ref _cacheLookup ) ;
942
943
if ( HasSlicer )
@@ -962,15 +963,18 @@ private void UpdatePivotItemsFromSharedItems(HashSet<object> siHs)
962
963
var hasFilter = list . Any ( x => x . Hidden ) ;
963
964
for ( var ix = 0 ; ix < list . Count ; ix ++ )
964
965
{
965
- var v = list [ ix ] . Value ?? ExcelPivotTable . PivotNullValue ;
966
- if ( ! siHs . Contains ( v ) || existingItems . Contains ( v ) )
967
- {
968
- list . RemoveAt ( ix ) ;
969
- ix -- ;
970
- }
971
- else
966
+ if ( list [ ix ] . Type == eItemType . Data )
972
967
{
973
- existingItems . Add ( v ) ;
968
+ var v = list [ ix ] . Value ?? ExcelPivotTable . PivotNullValue ;
969
+ if ( ! siHs . Contains ( v ) || existingItems . Contains ( v ) )
970
+ {
971
+ list . RemoveAt ( ix ) ;
972
+ ix -- ;
973
+ }
974
+ else
975
+ {
976
+ existingItems . Add ( v ) ;
977
+ }
974
978
}
975
979
}
976
980
var hasSubTotalSubt = list . Count > 0 && list [ list . Count - 1 ] . Type == eItemType . Default ? 1 : 0 ;
@@ -1106,38 +1110,4 @@ internal Dictionary<object, int> GetCacheLookup()
1106
1110
}
1107
1111
1108
1112
}
1109
-
1110
- internal class CacheComparer : IEqualityComparer < object >
1111
- {
1112
- public new bool Equals ( object x , object y )
1113
- {
1114
- x = GetCaseInsensitiveValue ( x ) ;
1115
- y = GetCaseInsensitiveValue ( y ) ;
1116
- return x . Equals ( y ) ;
1117
- }
1118
-
1119
- private static object GetCaseInsensitiveValue ( object x )
1120
- {
1121
- if ( x == null || x . Equals ( ExcelPivotTable . PivotNullValue ) ) return ExcelPivotTable . PivotNullValue ;
1122
-
1123
- if ( x is string sx )
1124
- {
1125
- return sx . ToLower ( ) ;
1126
- }
1127
- else if ( x is char cx )
1128
- {
1129
- return char . ToLower ( cx ) . ToString ( ) ;
1130
- }
1131
- if ( ConvertUtil . IsExcelNumeric ( x ) )
1132
- {
1133
- return ConvertUtil . GetValueDouble ( x ) ;
1134
- }
1135
- return x . ToString ( ) . ToLower ( ) ;
1136
- }
1137
-
1138
- public int GetHashCode ( object obj )
1139
- {
1140
- return GetCaseInsensitiveValue ( obj ) . GetHashCode ( ) ;
1141
- }
1142
- }
1143
1113
}
0 commit comments