Få cellområde
Contents
[
Hide
]
Möjliga användningsscenario
När du bara behöver manipulera viss data på kalkylarket behöver du veta dataräckvidden för hela kalkylarket. Aspose.Cells for Python via .NET erbjuder denna funktion. Aspose.Cells for Python via .NET tillhandahåller följande egenskaper och metoder för att hjälpa dig att uppnå dina mål.
Få cellområde med hjälp av Aspose.Cells
Detta exempel visar hur man:
- Skapa en arbetsbok.
- Lägga till data till celler i den första arbetsboken.
- Få celler Range.
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 Workbook | |
from aspose.pydrawing import Color | |
# Instantiating an Workbook object | |
workbook = Workbook() | |
# Obtaining the reference of the newly added worksheet | |
ws = workbook.worksheets[0] | |
cells = ws.cells | |
# Setting the value to the cells | |
cell = cells.get("A1") | |
cell.put_value("Fruit") | |
cell = cells.get("B1") | |
cell.put_value("Count") | |
cell = cells.get("C1") | |
cell.put_value("Price") | |
cell = cells.get("A2") | |
cell.put_value("Apple") | |
cell = cells.get("A3") | |
cell.put_value("Mango") | |
cell = cells.get("A4") | |
cell.put_value("Blackberry") | |
cell = cells.get("A5") | |
cell.put_value("Cherry") | |
cell = cells.get("B2") | |
cell.put_value(5) | |
cell = cells.get("B3") | |
cell.put_value(3) | |
cell = cells.get("B4") | |
cell.put_value(6) | |
cell = cells.get("B5") | |
cell.put_value(4) | |
cell = cells.get("C2") | |
cell.put_value(5) | |
cell = cells.get("C3") | |
cell.put_value(20) | |
cell = cells.get("C4") | |
cell.put_value(30) | |
cell = cells.get("C5") | |
cell.put_value(60) | |
cell = cells.get("E10") | |
temp = workbook.create_style() | |
temp.font.color = Color.red | |
cell.set_style(temp) | |
# Get max display range of worksheet | |
range = cells.max_display_range | |
# get maximum row index of cell which contains data or style. | |
print(cells.max_row) | |
# get maximum row index of cell which contains data. | |
print(cells.max_data_row) | |
# get maximum column index of cell which contains data or style. | |
print(cells.max_column) | |
# get maximum column index of cell which contains data. | |
print(cells.max_data_column) |