スライサーの書式設定
Contents
[
Hide
]
考えられる使用シナリオ
Microsoft Excel では、列数を設定するか、スタイルなどを設定することで、スライサーをフォーマットできます。Aspose.Cells では、Slicer.NumberOfColumnsとSlicer.StyleTypeプロパティ。
スライサーの書式設定
次のコードを参照してください。サンプル 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); |