Bir Çalışma Sayfasının Cells'ine Erişme
Contents
[
Hide
]
Cells’e erişim
Aspose.Cells for Python via Java, bir çalışma sayfasındaki hücrelere, hücre adını veya satır ve sütun indeksini kullanarak erişmenizi sağlar. Bu makale, bir çalışma sayfasındaki hücrelere erişmek için kullanılan bu iki yaklaşımı da göstermektedir.
Hücre adını kullanarak hücreye erişme
Aşağıdaki kod parçacığı, hücre adını kullanarak hücreye erişmeyi gösterir. Örnek kod, “C5” hücresine erişir ve değerini yazdırır.
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
source_directory = "Examples/SampleFiles/SourceDirectory/" | |
# Instantiating a Workbook object | |
workbook = Workbook(source_directory + "Book1.xlsx") | |
# Accessing the worksheet in the Excel file | |
worksheet = workbook.getWorksheets().get(0) | |
cells = worksheet.getCells() | |
# Accessing a cell using its name | |
cell = cells.get("C5") | |
# Print Message | |
print("Cell Value: " + str(cell.getValue())) |
Satır ve sütun dizinini kullanarak hücreye erişme
Aşağıdaki kod parçacığı, satır ve sütun dizinini kullanarak hücreye erişmeyi gösterir. Örnek kod, satır dizini 4 ve hücre dizini 2 ile tanımlanan “C5” hücresinin değerine erişir ve bu değeri yazdırır.
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
source_directory = "Examples/SampleFiles/SourceDirectory/" | |
# Instantiating a Workbook object | |
workbook = Workbook(source_directory + "Book1.xlsx") | |
# Accessing the worksheet in the Excel file | |
worksheet = workbook.getWorksheets().get(0) | |
cells = worksheet.getCells() | |
# Accessing a cell using the row and column index | |
cell = cells.get(4, 2) | |
# Print Message | |
print("Cell Value: " + str(cell.getValue())) |