Class Slicer
Namespace: Aspose.Cells.Slicers
Assembly: Aspose.Cells.dll (25.2.0)
summary description of Slicer View
public class Slicer
Inheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
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;
SlicerCacheItemCollection items = slicer.SlicerCache.SlicerCacheItems;
SlicerCacheItem item = items[0];
item.Selected = false;
//do your business
book.Save("out.xlsx");
Dim book As Workbook = New Workbook()
Dim sheet As Worksheet = book.Worksheets(0)
Dim cells As 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
Dim pivots As PivotTableCollection = sheet.PivotTables
Dim pivotIndex As Int32 = pivots.Add("=Sheet1!A1:C9", "A12", "TestPivotTable")
Dim pivot As PivotTable = 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()
Dim slicers As SlicerCollection = sheet.Slicers
Dim slicerIndex As Int32 = slicers.Add(pivot, "E12", "fruit")
Dim slicer As Slicer = slicers(slicerIndex)
slicer.StyleType = SlicerStyleType.SlicerStyleLight2
Dim items As SlicerCacheItemCollection = slicer.SlicerCache.SlicerCacheItems
Dim item As SlicerCacheItem = items(0)
item.Selected = False
book.Save("out_vb.xlsx")
Properties
AlternativeText
Returns or sets the descriptive (alternative) text string of the Slicer object.
public string AlternativeText { get; set; }
Property Value
Examples
csharp
[C#]
slicer.AlternativeText = "AlternativeText test";
Caption
Returns or sets the caption of the specified slicer.
public string Caption { get; set; }
Property Value
Examples
csharp
[C#]
slicer.Caption = "slicer caption";
CaptionVisible
Returns or sets whether the header that displays the slicer Caption is visible the default value is true
public bool CaptionVisible { get; set; }
Property Value
Examples
csharp
[C#]
slicer.CaptionVisible = true;
ColumnWidth
Returns or sets the width, in points, of each column in the slicer.
public double ColumnWidth { get; set; }
Property Value
Examples
csharp
[C#]
slicer.ColumnWidth = 80;
ColumnWidthPixel
Gets or sets the width in unit of pixels for each column of the slicer.
public int ColumnWidthPixel { get; set; }
Property Value
Examples
csharp
[C#]
slicer.ColumnWidthPixel = 120;
Height
Returns or sets the height of the specified slicer, in points.
public double Height { get; set; }
Property Value
Examples
csharp
[C#]
slicer.Height = 120;
HeightPixel
Returns or sets the height of the specified slicer, in pixels.
public int HeightPixel { get; set; }
Property Value
Examples
csharp
[C#]
slicer.HeightPixel = 150;
IsLocked
Indicates whether the slicer shape is locked.
public bool IsLocked { get; set; }
Property Value
Examples
csharp
[C#]
slicer.IsLocked = false;
IsPrintable
Indicates whether the slicer object is printable.
public bool IsPrintable { get; set; }
Property Value
Examples
csharp
[C#]
slicer.IsPrintable = true;
LeftPixel
Returns or sets the horizontal offset of slicer shape from its left column, in pixels.
public int LeftPixel { get; set; }
Property Value
Examples
csharp
[C#]
slicer.LeftPixel = 2;
LockedAspectRatio
Indicates whether locking aspect ratio.
public bool LockedAspectRatio { get; set; }
Property Value
Examples
csharp
[C#]
slicer.LockedAspectRatio = true;
LockedPosition
Indicates whether the specified slicer can be moved or resized by using the user interface.
public bool LockedPosition { get; set; }
Property Value
Examples
csharp
[C#]
slicer.LockedPosition = false;
Name
Returns or sets the name of the specified slicer
public string Name { get; set; }
Property Value
Examples
csharp
[C#]
slicer.Name = "slicer name";
NumberOfColumns
Returns or sets the number of columns in the specified slicer.
public int NumberOfColumns { get; set; }
Property Value
Examples
csharp
[C#]
slicer.NumberOfColumns = 1;
Parent
Returns the Aspose.Cells.Worksheet object which contains this slicer. Read-only.
public Worksheet Parent { get; }
Property Value
Examples
csharp
[C#]
Worksheet currSheet = slicer.Parent;
Placement
Represents the way the drawing object is attached to the cells below it. The property controls the placement of an object on a worksheet.
public PlacementType Placement { get; set; }
Property Value
Examples
csharp
[C#]
slicer.Placement = PlacementType.FreeFloating;
RowHeight
Returns or sets the height, in points, of each row in the specified slicer.
public double RowHeight { get; set; }
Property Value
Examples
csharp
[C#]
slicer.RowHeight = 20;
RowHeightPixel
Returns or sets the height, in pixels, of each row in the specified slicer.
public int RowHeightPixel { get; set; }
Property Value
Examples
csharp
[C#]
slicer.RowHeightPixel = 30;
SlicerCache
Returns the SlicerCache object associated with the slicer. Read-only.
public SlicerCache SlicerCache { get; }
Property Value
Examples
csharp
[C#]
SlicerCache slicerCache = slicer.SlicerCache;
StyleType
Specify the type of Built-in slicer style the default type is SlicerStyleLight1
public SlicerStyleType StyleType { get; set; }
Property Value
Examples
csharp
[C#]
slicer.StyleType = SlicerStyleType.SlicerStyleLight2;
Title
Specifies the title of the current Slicer object.
public string Title { get; set; }
Property Value
Examples
csharp
[C#]
slicer.Title = "slicer title";
TopPixel
Returns or sets the vertical offset of slicer shape from its top row, in pixels.
public int TopPixel { get; set; }
Property Value
Examples
csharp
[C#]
slicer.TopPixel = 6;
Width
Returns or sets the width of the specified slicer, in points.
public double Width { get; set; }
Property Value
Examples
csharp
[C#]
slicer.Width = 100;
WidthPixel
Returns or sets the width of the specified slicer, in pixels.
public int WidthPixel { get; set; }
Property Value
Examples
csharp
[C#]
slicer.WidthPixel = 120;
Methods
AddPivotConnection(PivotTable)
Adds PivotTable connection.
public void AddPivotConnection(PivotTable pivot)
Parameters
pivot
PivotTable
The PivotTable object
Examples
csharp
[C#]
slicer.AddPivotConnection(pivot);
Refresh()
Refreshing the slicer.Meanwhile, Refreshing and Calculating relative PivotTables.
public void Refresh()
Examples
csharp
[C#]
slicer.Refresh();
RemovePivotConnection(PivotTable)
Removes PivotTable connection.
public void RemovePivotConnection(PivotTable pivot)
Parameters
pivot
PivotTable
The PivotTable object
Examples
csharp
[C#]
slicer.RemovePivotConnection(pivot);