特定のスタイルを持つセルを検索

Contents
[ ]

この例のコードは、セルA1と同じスタイルのすべてのセルを見つけます。コードが実行された後、A1と同じスタイルのすべてのセルにはテキスト「Found」が含まれます。

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)