Documents for Excel .NET Edition | GCDocuments
Features / Slicer / Slicer Style / Modify Slicer with Custom Style
In This Topic
    Modify Slicer with Custom Style
    In This Topic

    In GcExcel .NET, you can define your own custom style and add it in the slicer cache to modify your slicer as per your preferences.

    Refer to the following example code to see how you can modify your slicer with custom style.

    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);
    ITableStyle slicerStyle = workbook.TableStyles.Add("test");
    slicerStyle.ShowAsAvailableSlicerStyle = true;
    slicerStyle.TableStyleElements[TableStyleElementType.WholeTable].Font.Name = "Arial";
    slicerStyle.TableStyleElements[TableStyleElementType.WholeTable].Font.Bold = false;
    slicerStyle.TableStyleElements[TableStyleElementType.WholeTable].Font.Italic = false;
    slicerStyle.TableStyleElements[TableStyleElementType.WholeTable].Font.Color = Color.White;
    slicerStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders.Color = Color.Red;
    slicerStyle.TableStyleElements[TableStyleElementType.WholeTable].Interior.Color = Color.Green;
    slicer1.Style = slicerStyle;