スライサーの書式を設定する
Contents
[
Hide
]
スライサーの書式設定
Microsoft Excelを使用して、スライサーの列数やスタイルなどを設定することができます。Aspose.Cells for Python via Java では、Slicer.NumberOfColumnsおよびSlicer.StyleType プロパティを提供しています。
次のコードスニペットは、スライサーを含むsample Excel fileをロードし、スライサーにアクセスし、列数とスタイルタイプを設定して、output Excel fileとして保存します。スクリーンショットは、サンプルコードの実行後のスライサーの表示を示しています。
サンプルコード
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
import jpype | |
import asposecells | |
jpype.startJVM() | |
from asposecells.api import Workbook, SaveFormat, SlicerStyleType | |
# Load Source Excel file | |
workbook = Workbook("sampleFormattingSlicer.xlsx") | |
# Access first worksheet | |
worksheet = workbook.getWorksheets().get(0) | |
# Access the newly added slicer from slicer collection | |
slicer = worksheet.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 | |
workbook.save("outputFormattingSlicer.xlsx", SaveFormat.XLSX) | |
jpype.shutdownJVM() |