当切片器没筛选时,透视表里面筛选的单元格是 (全部)。筛选之后,透视表里面筛选的单元格为筛选的值。但再次全选之后,透视表里面筛选的单元格还是筛选的值,而不是全部。
示例代码:
using Aspose.Cells;
var wb = new Workbook("input.xlsx");
var ws = wb.Worksheets[0];
ws.RefreshPivotTables();
var targetCell = ws.Cells["E1"];
// print: (All)
Console.WriteLine(targetCell.Value);
var slicer = ws.Slicers[0];
// select alex
foreach (var cacheItem in slicer.SlicerCache.SlicerCacheItems)
{
cacheItem.Selected = cacheItem.Value == "Alex";
}
slicer.Refresh();
// print: Alex
Console.WriteLine(targetCell.Value);
// select all
foreach (var cacheItem in slicer.SlicerCache.SlicerCacheItems)
{
cacheItem.Selected = true;
}
slicer.Refresh();
// print: Alex
// expected: (All)
Console.WriteLine(targetCell.Value);
样例文件:
input.zip (11.5 KB)