格式化切片器

可能的使用场景

您可以通过设置其列数或设置其样式等在 Microsoft Excel 中格式化切片器。Aspose.Cells 还允许您使用切片器.NumberOfColumns切片器样式类型特性。

格式化切片器

请看下面的代码,它加载了示例 Excel 文件包含一个切片器。它访问切片器并设置其列数和样式类型并将其另存为输出Excel文件.屏幕截图显示了切片器在执行示例代码后的样子。

待办事项:图片_替代_文本

示例代码

// 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);