Hitta celler med specifik stil
Contents
[
Hide
]
Ibland behöver du hitta celler med en särskild stil applicerad. Du kan använda Aspose.Cells for Python via .NET för att hitta alla celler med en gemensam stil. Aspose.Cells for Python via .NET tillhandahåller egenskapen FindOptions.style som du kan använda för att specificera stilen att söka celler för.
Koden i detta exempel hittar alla celler som har samma stil som cell A1. Efter att koden har utförts innehåller alla celler som har samma stil som A1 texten “Hittad”.
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 FindOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
filePath = "TestBook.xlsx" | |
workbook = Workbook(filePath) | |
worksheet = workbook.worksheets[0] | |
# Access the style of cell A1 | |
style = worksheet.cells.get("A1").get_style() | |
# Specify the style for searching | |
options = FindOptions() | |
options.style = style | |
nextCell = None | |
while True: | |
# Find the cell that has a style of cell A1 | |
nextCell = worksheet.cells.find(None, nextCell, options) | |
if nextCell == None: | |
break | |
# Change the text of the cell | |
nextCell.put_value("Found") | |
dataDir = "output.out.xlsx" | |
workbook.save(dataDir) |