Use Do Filter Operation

Spread.Services Documentation
Use Do Filter Operation
Collapse All Expand All

Spread.Services Documentation > Developer's Guide > Manage Data in Spread Component > Use Slicer > Use Do Filter Operation

You can set slicer filters to analyse bulk information in a spreadsheet quickly and efficiently.

### Use slicer do-filter operation

Refer to the following example code to use slicer to perform do-filter operation.

C# | Copy Code
--- | ---

    // Adding data to the table
    worksheet.Range["A1:F16"].Value = sourceData;
    ITable table = worksheet.Tables.Add(worksheet.Range["A1:F16"], true);
    ISlicerCache cache = workbook.SlicerCaches.Add(table, "Category", "categoryCache");
    // Add slicer for table
    ISlicer slicer1 = cache.Slicers.Add(workbook.Worksheets["Sheet1"], "cate1", "Category", 200, 200, 100, 200);
    ISlicer slicer2 = cache.Slicers.Add(workbook.Worksheets["Sheet1"], "cate2", "Category", 100, 100, 100, 200);

    //do filter operation.
    slicer1.SlicerCache.SlicerItems["Vegetables"].Selected = false;

### Clear slicer filter

Refer to the following example code to clear slicer filter.

C# | Copy Code
--- | ---

    // Adding data to the table
    worksheet.Range["A1:F16"].Value = sourceData;
    ITable table = worksheet.Tables.Add(worksheet.Range["A1:F16"], true);
    ISlicerCache cache = workbook.SlicerCaches.Add(table, "Category", "categoryCache");
    // Add slicer for table
    ISlicer slicer1 = cache.Slicers.Add(workbook.Worksheets["Sheet1"], "cate1", "Category", 200, 200, 100, 200);
    ISlicer slicer2 = cache.Slicers.Add(workbook.Worksheets["Sheet1"], "cate2", "Category", 100, 100, 100, 200);

    //do filter operation.
    slicer1.SlicerCache.SlicerItems["Vegetables"].Selected = false;

    //clear filter.
    slicer1.SlicerCache.ClearAllFilters();

Copyright © GrapeCity, inc. All rights reserved.