格式化切片器

可能的使用场景

您可以通过设置其列数或样式等属性,在Microsoft Excel中格式化切片器。Aspose.Cells也允许您通过Slicer.NumberOfColumnsSlicer.StyleType属性来执行此操作。

格式化切片器

请参阅以下代码,它加载了包含切片器的sample Excel file。它访问该切片器并设置其列数和样式类型,然后将其保存为output Excel file。截图展示了在执行示例代码后切片器的外观。

todo:image_alt_text

示例代码

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Load sample Excel file containing slicer.
Workbook wb = new Workbook("sampleFormattingSlicer.xlsx");
// Access first worksheet.
Worksheet ws = wb.Worksheets[0];
// Access the first slicer inside the slicer collection.
Aspose.Cells.Slicers.Slicer slicer = ws.Slicers[0];
// Set the number of columns of the slicer.
slicer.NumberOfColumns = 2;
// Set the type of slicer style.
slicer.StyleType = Aspose.Cells.Slicers.SlicerStyleType.SlicerStyleLight6;
// Save the workbook in output XLSX format.
wb.Save("outputFormattingSlicer.xlsx", SaveFormat.Xlsx);