スライサーの書式を設定する

可能な使用シナリオ

Microsoft Excelでスライサーをフォーマットすることができます。Aspose.Cellsでも、Slicer.NumberOfColumns およびSlicer.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-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);