条件付き書式で使用されるアイコンセット、データバーやカラースケールのオブジェクトを取得する
Contents
[
Hide
]
時には、条件付き書式で使用されているアイコンセットを取得し、それに基づいた画像ファイルを作成したい場合があります。条件付き書式で使用されているデータバーやカラースケールを読む必要があるかもしれません。Aspose.Cells for Python via .NETはこの機能をサポートします。
次のコードサンプルは、条件付き書式で使用されるアイコンセットを読み取る方法を示しています。Aspose.CellのシンプルなAPIを使用して、アイコンセットの画像データが画像として保存されます。
This file contains hidden or 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 Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Open a template Excel file | |
workbook = Workbook(dataDir + "book1.xlsx") | |
# Get the first worksheet in the workbook | |
sheet = workbook.worksheets[0] | |
# Get the A1 cell | |
cell = sheet.cells.get("A1") | |
# Get the conditional formatting result object | |
cfr = cell.get_conditional_formatting_result() | |
# Get the icon set | |
icon = cfr.conditional_formatting_icon | |
# Create the image file based on the icon's image data | |
with open(dataDir + "imgIcon.out.jpg", "wb") as f: | |
f.write(icon.image_data) |