Aspose::Cells::Slicers::Slicer class

Slicer class

summary description of Slicer View

class Slicer

Methods

MethodDescription
AddPivotConnection(const PivotTable& pivot)Adds PivotTable connection.
GetAlternativeText()(Deprecated) Returns or sets the descriptive (alternative) text string of the Slicer object.
GetCaption()Returns or sets the caption of the specified slicer.
GetCaptionVisible()(Deprecated) Returns or sets whether the header that displays the slicer Caption is visible. The default value is true.
GetColumnWidth()Returns or sets the width of each column in the slicer in unit of points.
GetColumnWidthPixel()Gets or sets the width of each column in the slicer, in unit of pixels.
GetFirstItemIndex()Specifies the zero-based index of the first slicer item.
GetHeight()(Deprecated) Returns or sets the height of the specified slicer, in points.
GetHeightPixel()(Deprecated) Returns or sets the height of the specified slicer, in pixels.
GetLeftPixel()(Deprecated) Returns or sets the horizontal offset of slicer shape from its left column, in pixels.
GetLockedAspectRatio()(Deprecated) Indicates whether locking aspect ratio.
GetLockedPosition()Indicates whether the specified slicer can be moved or resized by using the user interface.
GetName()Returns or sets the name of the specified slicer.
GetNumberOfColumns()Returns or sets the number of columns in the specified slicer. The default value is 1.
GetParent()(Deprecated) Returns the Worksheet object which contains this slicer. Read-only.
GetPlacement()(Deprecated) Represents the way the drawing object is attached to the cells below it. The property controls the placement of an object on a worksheet.
GetRowHeight()Returns or sets the height of each row in the specified slicer in unit of points.
GetRowHeightPixel()Returns or sets the height of each row in the specified slicer, in unit of pixels.
GetShape()Returns the Shape object associated with the specified slicer. Read-only.
GetShowAllItems()Indicates whether to show all items even if there are no data or they are deleted. Default value is true;.
GetShowCaption()Indicates whether the header of the slicer is visible. The default value is true.
GetShowMissing()Indicates whether to show items deteleted from the data source.
GetShowTypeOfItemsWithNoData()Indicates whether to show items deteleted from the data source.
GetSlicerCache()Returns the SlicerCache object associated with the slicer. Read-only.
GetSortOrderType()Indicates the type of sorting items.
GetStyleType()Specify the type of Built-in slicer style. The default type is SlicerStyleLight1.
GetTitle()(Deprecated) Specifies the title of the current Slicer object.
GetTopPixel()(Deprecated) Returns or sets the vertical offset of slicer shape from its top row, in pixels.
GetWidth()(Deprecated) Returns or sets the width of the specified slicer, in points.
GetWidthPixel()(Deprecated) Returns or sets the width of the specified slicer, in pixels.
GetWorksheet()Returns the Worksheet object which contains this slicer. Read-only.
IsLocked()(Deprecated) Indicates whether the slicer shape is locked.
IsNull() constChecks whether the implementation object is nullptr.
IsPrintable()(Deprecated) Indicates whether the slicer object is printable.
explicit operator bool() constoperator bool()
operator=(const Slicer& src)operator=
Refresh()Refreshing the slicer. Meanwhile, Refreshing and Calculating PivotTables which this slicer based on.
RemovePivotConnection(const PivotTable& pivot)Removes PivotTable connection.
SetAlternativeText(const U16String& value)(Deprecated) Returns or sets the descriptive (alternative) text string of the Slicer object.
SetAlternativeText(const char16_t* value)(Deprecated) Returns or sets the descriptive (alternative) text string of the Slicer object.
SetCaption(const U16String& value)Returns or sets the caption of the specified slicer.
SetCaption(const char16_t* value)Returns or sets the caption of the specified slicer.
SetCaptionVisible(bool value)(Deprecated) Returns or sets whether the header that displays the slicer Caption is visible. The default value is true.
SetColumnWidth(double value)Returns or sets the width of each column in the slicer in unit of points.
SetColumnWidthPixel(int32_t value)Gets or sets the width of each column in the slicer, in unit of pixels.
SetFirstItemIndex(int32_t value)Specifies the zero-based index of the first slicer item.
SetHeight(double value)(Deprecated) Returns or sets the height of the specified slicer, in points.
SetHeightPixel(int32_t value)(Deprecated) Returns or sets the height of the specified slicer, in pixels.
SetIsLocked(bool value)(Deprecated) Indicates whether the slicer shape is locked.
SetIsPrintable(bool value)(Deprecated) Indicates whether the slicer object is printable.
SetLeftPixel(int32_t value)(Deprecated) Returns or sets the horizontal offset of slicer shape from its left column, in pixels.
SetLockedAspectRatio(bool value)(Deprecated) Indicates whether locking aspect ratio.
SetLockedPosition(bool value)Indicates whether the specified slicer can be moved or resized by using the user interface.
SetName(const U16String& value)Returns or sets the name of the specified slicer.
SetName(const char16_t* value)Returns or sets the name of the specified slicer.
SetNumberOfColumns(int32_t value)Returns or sets the number of columns in the specified slicer. The default value is 1.
SetPlacement(PlacementType value)(Deprecated) Represents the way the drawing object is attached to the cells below it. The property controls the placement of an object on a worksheet.
SetRowHeight(double value)Returns or sets the height of each row in the specified slicer in unit of points.
SetRowHeightPixel(int32_t value)Returns or sets the height of each row in the specified slicer, in unit of pixels.
SetShowAllItems(bool value)Indicates whether to show all items even if there are no data or they are deleted. Default value is true;.
SetShowCaption(bool value)Indicates whether the header of the slicer is visible. The default value is true.
SetShowMissing(bool value)Indicates whether to show items deteleted from the data source.
SetShowTypeOfItemsWithNoData(ItemsWithNoDataShowMode value)Indicates whether to show items deteleted from the data source.
SetSortOrderType(SortOrder value)Indicates the type of sorting items.
SetStyleType(SlicerStyleType value)Specify the type of Built-in slicer style. The default type is SlicerStyleLight1.
SetTitle(const U16String& value)(Deprecated) Specifies the title of the current Slicer object.
SetTitle(const char16_t* value)(Deprecated) Specifies the title of the current Slicer object.
SetTopPixel(int32_t value)(Deprecated) Returns or sets the vertical offset of slicer shape from its top row, in pixels.
SetWidth(double value)(Deprecated) Returns or sets the width of the specified slicer, in points.
SetWidthPixel(int32_t value)(Deprecated) Returns or sets the width of the specified slicer, in pixels.
Slicer(Slicer_Impl* impl)Constructs from an implementation object.
Slicer(const Slicer& src)Copy constructor.
~Slicer()Destructor.

Fields

FieldDescription
_implThe implementation object.

Examples

Aspose::Cells::Startup();
Workbook book;
Worksheet sheet = book.GetWorksheets().Get(0);
Cells cells = sheet.GetCells();
cells.Get(0, 0).PutValue(u"fruit");
cells.Get(1, 0).PutValue(u"grape");
cells.Get(2, 0).PutValue(u"blueberry");
cells.Get(3, 0).PutValue(u"kiwi");
cells.Get(4, 0).PutValue(u"cherry");
cells.Get(5, 0).PutValue(u"grape");
cells.Get(6, 0).PutValue(u"blueberry");
cells.Get(7, 0).PutValue(u"kiwi");
cells.Get(8, 0).PutValue(u"cherry");

cells.Get(0, 1).PutValue(u"year");
cells.Get(1, 1).PutValue(2020);
cells.Get(2, 1).PutValue(2020);
cells.Get(3, 1).PutValue(2020);
cells.Get(4, 1).PutValue(2020);
cells.Get(5, 1).PutValue(2021);
cells.Get(6, 1).PutValue(2021);
cells.Get(7, 1).PutValue(2021);
cells.Get(8, 1).PutValue(2021);

cells.Get(0, 2).PutValue(u"amount");
cells.Get(1, 2).PutValue(50);
cells.Get(2, 2).PutValue(60);
cells.Get(3, 2).PutValue(70);
cells.Get(4, 2).PutValue(80);
cells.Get(5, 2).PutValue(90);
cells.Get(6, 2).PutValue(100);
cells.Get(7, 2).PutValue(110);
cells.Get(8, 2).PutValue(120);

PivotTableCollection pivots = sheet.GetPivotTables();

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

pivot.SetPivotTableStyleType(PivotTableStyleType::PivotTableStyleMedium10);
pivot.RefreshData();
pivot.CalculateData();

SlicerCollection slicers = sheet.GetSlicers();
int slicerIndex = slicers.Add(pivot, u"E12", u"fruit");
Slicer slicer = slicers.Get(slicerIndex);
slicer.SetStyleType(SlicerStyleType::SlicerStyleLight2);

SlicerCacheItemCollection items = slicer.GetSlicerCache().GetSlicerCacheItems();
SlicerCacheItem item = items.Get(0);
item.SetSelected(false);
book.Save("out.xlsx");
Aspose::Cells::Cleanup();

See Also