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

可能な使用シナリオ

Microsoft Excelでスライサーの列数を設定したり、スタイルなどを設定することでスライサーの形式を設定できます。Aspose.Cellsでも、これらの設定を使用して行うことができます。

スライサーの書式設定

以下のコードをご覧ください。スライサーを含むsample Excelファイルを読み込み、スライサーにアクセスしてその列数やスタイルタイプを設定し、output Excelファイルとして保存します。スクリーンショットは、サンプルコードの実行後のスライサーの見た目を示しています。

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