@@ -255,6 +255,102 @@ slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2
255255{% endhighlight %}
256256{% endtabs %}
257257
258+ ### Select a Slicer Item
259+
260+ The following example shows how to select items in a slicer.
261+
262+ {% tabs %}
263+ {% highlight c# tabtitle="C# [ Cross-platform] " %}
264+ ISlicer slicer = sheet.Slicers[ 0] ;
265+ ISlicerCache cache = slicer.SlicerCache;
266+ cache.SlicerCacheItems[ 0] .IsSelected = true;
267+ {% endhighlight %}
268+
269+ {% highlight c# tabtitle="C# [ Windows-specific] " %}
270+ ISlicer slicer = sheet.Slicers[ 0] ;
271+ ISlicerCache cache = slicer.SlicerCache;
272+ cache.SlicerCacheItems[ 0] .IsSelected = true;
273+ {% endhighlight %}
274+
275+ {% highlight vb.net tabtitle="VB.NET [ Windows-specific] " %}
276+ Dim slicer As ISlicer = sheet.Slicers(0)
277+ Dim cache As ISlicerCache = slicer.SlicerCache
278+ cache.SlicerCacheItems(0).IsSelected = True
279+ {% endhighlight %}
280+ {% endtabs %}
281+
282+ ### Select slicer filter type
283+
284+ The following example shows how to select the slicer filter type.
285+
286+ {% tabs %}
287+ {% highlight c# tabtitle="C# [ Cross-platform] " %}
288+ ISlicer slicer = sheet.Slicers[ 0] ;
289+ ISlicerCache cache = slicer.SlicerCache;
290+ cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop;
291+ {% endhighlight %}
292+
293+ {% highlight c# tabtitle="C# [ Windows-specific] " %}
294+ ISlicer slicer = sheet.Slicers[ 0] ;
295+ ISlicerCache cache = slicer.SlicerCache;
296+ cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop;
297+ {% endhighlight %}
298+
299+ {% highlight vb.net tabtitle="VB.NET [ Windows-specific] " %}
300+ Dim slicer As ISlicer = sheet.Slicers(0)
301+ Dim cache As ISlicerCache = slicer.SlicerCache
302+ cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop
303+ {% endhighlight %}
304+ {% endtabs %}
305+
306+ ### Sort the slicer items
307+
308+ The following example shows how to sort the slicer items.
309+
310+ {% tabs %}
311+ {% highlight c# tabtitle="C# [ Cross-platform] " %}
312+ ISlicer slicer = sheet.Slicers[ 0] ;
313+ ISlicerCache cache = slicer.SlicerCache;
314+ cache.IsAscending = true;
315+ {% endhighlight %}
316+
317+ {% highlight c# tabtitle="C# [ Windows-specific] " %}
318+ ISlicer slicer = sheet.Slicers[ 0] ;
319+ ISlicerCache cache = slicer.SlicerCache;
320+ cache.IsAscending = true;
321+ {% endhighlight %}
322+
323+ {% highlight vb.net tabtitle="VB.NET [ Windows-specific] " %}
324+ Dim slicer As ISlicer = sheet.Slicers(0)
325+ Dim cache As ISlicerCache = slicer.SlicerCache
326+ cache.IsAscending = True
327+ {% endhighlight %}
328+ {% endtabs %}
329+
330+ ### Sort the slicer items using Custom list sorting option
331+
332+ The following example shows how to sort the slicer items using Custom list sorting option
333+
334+ {% tabs %}
335+ {% highlight c# tabtitle="C# [ Cross-platform] " %}
336+ ISlicer slicer = sheet.Slicers[ 0] ;
337+ ISlicerCache cache = slicer.SlicerCache;
338+ cache.UseCustomListSorting = true;
339+ {% endhighlight %}
340+
341+ {% highlight c# tabtitle="C# [ Windows-specific] " %}
342+ ISlicer slicer = sheet.Slicers[ 0] ;
343+ ISlicerCache cache = slicer.SlicerCache;
344+ cache.UseCustomListSorting = true;
345+ {% endhighlight %}
346+
347+ {% highlight vb.net tabtitle="VB.NET [ Windows-specific] " %}
348+ Dim slicer As ISlicer = sheet.Slicers(0)
349+ Dim cache As ISlicerCache = slicer.SlicerCache
350+ cache.UseCustomListSorting = True
351+ {% endhighlight %}
352+ {% endtabs %}
353+
258354The following code snippet illustrates how to format an existing slicer with all the above discussed properties.
259355
260356{% tabs %}
@@ -301,6 +397,19 @@ using (ExcelEngine excelEngine = new ExcelEngine())
301397
302398 //Slicer style
303399 slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2;
400+
401+ //Select the slicer item
402+ ISlicerCache cache = slicer.SlicerCache;
403+ cache.SlicerCacheItems[ 0] .IsSelected = true;
404+
405+ //Set the slicer filter type
406+ cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop;
407+
408+ //Sort the slicer items in ascending order
409+ cache.IsAscending = true;
410+
411+ //Custom list sorting
412+ cache.UseCustomListSorting = true;
304413
305414 workbook.SaveAs("Output.xlsx");
306415}
@@ -349,6 +458,19 @@ using (ExcelEngine excelEngine = new ExcelEngine())
349458
350459 //Slicer style
351460 slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2;
461+
462+ //Select the slicer item
463+ ISlicerCache cache = slicer.SlicerCache;
464+ cache.SlicerCacheItems[ 0] .IsSelected = true;
465+
466+ //Set the slicer filter type
467+ cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop;
468+
469+ //Sort the slicer items in ascending order
470+ cache.IsAscending = true;
471+
472+ //Custom list sorting
473+ cache.UseCustomListSorting = true;
352474
353475 workbook.SaveAs("Output.xlsx");
354476}
@@ -396,6 +518,19 @@ Using excelEngine As ExcelEngine = New ExcelEngine
396518
397519 'Slicer style
398520 slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2
521+
522+ 'Select the slicer item
523+ Dim cache As ISlicerCache = slicer.SlicerCache
524+ cache.SlicerCacheItems(0).IsSelected = True
525+
526+ 'Set the slicer filter type
527+ cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop
528+
529+ 'Sort the slicer items in ascending order
530+ cache.IsAscending = True
531+
532+ 'Custom list sorting
533+ cache.UseCustomListSorting = True
399534
400535 workbook.SaveAs("Output.xlsx")
401536End Using
0 commit comments