格式化切片器
Contents
[
Hide
]
可能的使用场景
您可以通过设置其列数或设置其样式等方式在 Microsoft Excel 中格式化分析器。Aspose.Cells 也允许您使用 Slicer.NumberOfColumns 和 Slicer.StyleType 属性来执行此操作。
格式化切片器
请参阅以下代码,其中加载包含分析器的 示例 Excel 文件。访问分析器并设置其列数和样式类型,然后将其另存为 输出 Excel 文件。截图显示示例代码执行后分析器的外观。
示例代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// Load sample Excel file containing slicer. | |
Workbook wb = new Workbook(srcDir + "sampleFormattingSlicer.xlsx"); | |
// Access first worksheet. | |
Worksheet ws = wb.getWorksheets().get(0); | |
// Access the first slicer inside the slicer collection. | |
Slicer slicer = ws.getSlicers().get(0); | |
// Set the number of columns of the slicer. | |
slicer.setNumberOfColumns(2); | |
// Set the type of slicer style. | |
slicer.setStyleType(SlicerStyleType.SLICER_STYLE_LIGHT_6); | |
// Save the workbook in output XLSX format. | |
wb.save(outDir + "outputFormattingSlicer.xlsx", SaveFormat.XLSX); |