Document Solutions for Excel, .NET Edition | Document Solutions
Features / Slicer / Slicer Style
In This Topic
    Slicer Style
    In This Topic

    When you create a slicer, it is mandatory to create a slicer cache first and then use the slicer cache created base on the column of the table or the pivot table.

    The SlicerCaches collection in DsExcel .NET holds all the slicer caches in the workbook.

    Set slicer to built-in style

    You can set your slicer to built-in style by using the Style property of the ISlicer interface.

    Refer to the following example code to set slicer to built-in style.

    C#
    Copy Code
    //create slicer cache for table.
    ISlicerCache cache = workbook.SlicerCaches.Add(table, "Category", "categoryCache");
    
    //add slicer
    ISlicer slicer1 = cache.Slicers.Add(workbook.Worksheets["Sheet1"], "cate1", "Category", 200, 200, 100, 200);
    
    //set slicer style to build in style.
    slicer1.Style = workbook.TableStyles["SlicerStyleLight1"];