スライサーの書式を設定する
Contents
[
Hide
]
可能な使用シナリオ
Microsoft Excelでスライサの列数を設定したり、スタイルを設定することでスライサの書式を設定することができます。Aspose.Cells for Python via .NETでも、Slicer.number_of_columnsおよびSlicer.style_typeプロパティを使用して同様の操作を行うことができます。
Aspose.Cells for Python Excelライブラリを使用したスライサの書式設定方法
以下のコードをご覧ください。スライサーを含むsample Excelファイルを読み込み、スライサーにアクセスしてその列数やスタイルタイプを設定し、output 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
from aspose.cells import SaveFormat, Workbook | |
from aspose.cells.slicers import SlicerStyleType | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Load sample Excel file containing slicer. | |
wb = Workbook("sampleFormattingSlicer.xlsx") | |
# Access first worksheet. | |
ws = wb.worksheets[0] | |
# Access the first slicer inside the slicer collection. | |
slicer = ws.slicers[0] | |
# Set the number of columns of the slicer. | |
slicer.number_of_columns = 2 | |
# Set the type of slicer style. | |
slicer.style_type = SlicerStyleType.SLICER_STYLE_LIGHT6 | |
# Save the workbook in output XLSX format. | |
wb.save("outputFormattingSlicer.xlsx", SaveFormat.XLSX) |