We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Access to Slicer Item Label or Value in the worksheet in .NET

Is it possible to access the SlicerCacheItem label associated with the option in the Slicer? I need to pre-select a number of different options but when I look in the documentation the only usable property is Selected. I can loop through the index of SlicerCacheItems but because of different sorting, index-0 may not be the item I expect, and I would rather check the label of the option and decided to select or deselect it that way.

The commented-out bit in the following code is what I’m hoping to accomplish:

Worksheet cost = wb.Worksheets[“Cost”];
Slicer yrSlcr = cost.Slicers[“year_slicer”];
SlicerCacheItemCollection items = yrSlcr.SlicerCache.SlicerCacheItems;
List selectedOptions = new List() { “2018”, “2019”, “2020” };
for (int i = 0; i < items.Count; i++)
{
//SlicerCacheItem s = items[i];
//if (selectedOptions.Contains(s.Value.Tostring()))
//{
// s.Selected = true;
//} else
//{
// s.Selected = false;
//}
}
yrSlcr .Refresh();

Obviously, “s.Value” does not exist, but what, if any, options are there for accessing the value or text on the Slicer item?

Thanks.

@mfox,
Please elaborate the issue more by providing sample Excel file, images showing the required information and steps to perform the same task using MS Excel only. We will analyze the information and share our feedback accordingly.

Ok, but what does any of that have to do with my question? I’m asking about the Cells library, not a working solution.

@mfox,
We have further analyzed this requirement and logged it in our database for detailed investigation. You will be notified here once any update is ready for sharing.

This requirement is logged as:
CELLSNET-48104 - Get value of SlicerCacheItem in the collection Slicer.SlicerCache.SlicerCacheItems

It does appear to be possible in VBA by using this code in the attached spreadsheet.SlicerLabelsVBA.zip (22.8 KB)

Currently Aspose only allows indexing the slicer options by their index in the SlicerItemCacheCollection.

@mfox,
Thank you for providing more information. We have noted it with the ticket for our reference.

@mfox,

This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

Thank you. Looking forward to it.

@mfox,
Please try our latest version/fix: Aspose.Cells for .NET v21.5.5 (attached)
Aspose.Cells21.5.5 For .Net2_AuthenticodeSigned.Zip (5.5 MB)
Aspose.Cells21.5.5 For .Net4.0.Zip (5.5 MB)
Aspose.Cells21.5.5 For .NetStandard20.Zip (5.5 MB)

Your issue should be fixed in it.
Let us know your feedback.

The issues you have found earlier (filed as CELLSNET-48104) have been fixed in this update. This message was posted using Bugs notification tool by simon.zhao