Class SlicerCache

Class SlicerCache

Namespace: Aspose.Cells.Slicers
Assembly: Aspose.Cells.dll (25.2.0)

Represent summary description of slicer cache

public class SlicerCache

Inheritance

objectSlicerCache

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

csharp
[C#]

Workbook book = new Workbook();
Worksheet sheet = book.Worksheets[0];
Cells cells = sheet.Cells;
cells[0, 0].Value = "fruit";
cells[1, 0].Value = "grape";
cells[2, 0].Value = "blueberry";
cells[3, 0].Value = "kiwi";
cells[4, 0].Value = "cherry";
cells[5, 0].Value = "grape";
cells[6, 0].Value = "blueberry";
cells[7, 0].Value = "kiwi";
cells[8, 0].Value = "cherry";

cells[0, 1].Value = "year";
cells[1, 1].Value = 2020;
cells[2, 1].Value = 2020;
cells[3, 1].Value = 2020;
cells[4, 1].Value = 2020;
cells[5, 1].Value = 2021;
cells[6, 1].Value = 2021;
cells[7, 1].Value = 2021;
cells[8, 1].Value = 2021;

cells[0, 2].Value = "amount";
cells[1, 2].Value = 50;
cells[2, 2].Value = 60;
cells[3, 2].Value = 70;
cells[4, 2].Value = 80;
cells[5, 2].Value = 90;
cells[6, 2].Value = 100;
cells[7, 2].Value = 110;
cells[8, 2].Value = 120;

PivotTableCollection pivots = sheet.PivotTables;

int pivotIndex = pivots.Add("=Sheet1!A1:C9", "A12", "TestPivotTable");
PivotTable pivot = pivots[pivotIndex];
pivot.AddFieldToArea(PivotFieldType.Row, "fruit");
pivot.AddFieldToArea(PivotFieldType.Column, "year");
pivot.AddFieldToArea(PivotFieldType.Data, "amount");

pivot.PivotTableStyleType = PivotTableStyleType.PivotTableStyleMedium10;
pivot.RefreshData();
pivot.CalculateData();

SlicerCollection slicers = sheet.Slicers;
int slicerIndex = slicers.Add(pivot, "E12", "fruit");
Slicer slicer = slicers[slicerIndex];
slicer.StyleType = SlicerStyleType.SlicerStyleLight2;

//Get SlicerCache object of current slicer
SlicerCache slicerCache = slicer.SlicerCache;

//do your business

book.Save("out.xlsx");

Properties

CrossFilterType

Returns or sets whether a slicer is participating in cross filtering with other slicers that share the same slicer cache, and how cross filtering is displayed. Read/write

public SlicerCacheCrossFilterType CrossFilterType { get; set; }

Property Value

SlicerCacheCrossFilterType

List

Returns whether the slicer associated with the specified slicer cache is based on an Non-OLAP data source. Read-only

public bool List { get; }

Property Value

bool

Examples

csharp
[C#]

Console.WriteLine(slicerCache.List);

Name

Returns the name of the slicer cache.

public string Name { get; }

Property Value

string

Examples

csharp
[C#]

//get the name of the slicer cache.
Console.WriteLine(slicerCache.Name);

SlicerCacheItems

Returns a SlicerCacheItem collection that contains the collection of all items in the slicer cache. Read-only

public SlicerCacheItemCollection SlicerCacheItems { get; }

Property Value

SlicerCacheItemCollection

Examples

csharp
[C#]

//get SlicerCacheItem collection that contains the collection of all items in the slicer cache.
SlicerCacheItemCollection slicerCacheItems = slicerCache.SlicerCacheItems;
Console.WriteLine(slicerCacheItems.Count);

SourceName

Returns the name of this slicer cache.

public string SourceName { get; }

Property Value

string

Examples

csharp
[C#]

//get the name of this slicer cache.
Console.WriteLine(slicerCache.SourceName);