Obtener conjuntos de iconos, barras de datos o escalas de colores utilizadas en el formato condicional
Contents
[
Hide
]
A veces, necesitas obtener conjuntos de iconos usados en el formato condicional de una celda o rango de celdas y quieres crear un archivo de imagen basado en ello. Podrías necesitar leer las barras de datos o escalas de color usadas en el formato condicional. Aspose.Cells para Python via .NET soporta esta función.
El siguiente ejemplo de código muestra cómo leer conjuntos de iconos que se utilizan para el formato condicional. Con la API sencilla de Aspose.Cells, los datos de imagen del conjunto de iconos se guardan como una imagen.
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) |