Shape — Aspose.Cells FOSS for Python API Reference
aspose-cells-foss, çalışma sayfalarına geometrik şekiller ve metin kutuları eklemeyi destekler ShapeCollection (ws.shapes). Her şekil bir Shape nesnesi, yapılandırılabilir dolgu, çizgi ve metin özelliklerine sahiptir.
Enumerations: aspose.cells_foss
from aspose.cells_foss import (
MsoDrawingType, FillType, MsoLineDashStyle,
TextAlignmentType, TextAnchorType,
MsoFillFormat, MsoLineFormat, ShapeFont, Shape,
)MsoDrawingType
MsoDrawingType bir IntEnum geometrik şekil tipini tanımlayan.
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
UNKNOWN | 0 | TEXT_BOX | 21 |
RECTANGLE | 1 | CALLOUT | 22 |
ROUNDED_RECTANGLE | 2 | PENTAGON | 23 |
OVAL | 3 | CLOUD | 24 |
DIAMOND | 4 | HEART | 25 |
TRIANGLE | 5 | LIGHTNING_BOLT | 26 |
RIGHT_TRIANGLE | 6 | SMILEY_FACE | 27 |
PARALLELOGRAM | 7 | LEFT_RIGHT_ARROW | 28 |
TRAPEZOID | 8 | UP_DOWN_ARROW | 29 |
HEXAGON | 9 | CUBE | 30 |
OCTAGON | 10 | BEVEL | 31 |
CROSS | 11 | STAR_4 | 12 |
RIGHT_ARROW | 17 | STAR_5 | 13 |
LEFT_ARROW | 18 | STAR_6 | 14 |
UP_ARROW | 19 | STAR_7 | 15 |
DOWN_ARROW | 20 | STAR_8 | 16 |
FillType
FillType bir IntEnum bir şekle uygulanan dolgu tipini tanımlayan.
| Enumerations | Enumerations |
|---|---|
NONE | 0 |
SOLID | 1 |
GRADIENT | 2 |
PATTERN | 3 |
AUTOMATIC | 4 |
MsoLineDashStyle
MsoLineDashStyle bir IntEnum kenar/çerçeve çizgi kesikli deseni için.
| Enumerations | Enumerations |
|---|---|
SOLID | 0 |
DASH | 1 |
DOT | 2 |
DASH_DOT | 3 |
DASH_DOT_DOT | 4 |
LONG_DASH | 5 |
LONG_DASH_DOT | 6 |
TextAlignmentType
TextAlignmentType bir IntEnum bir şekil içinde yatay metin hizalaması için.
| Enumerations | Enumerations |
|---|---|
LEFT | 0 |
CENTER | 1 |
RIGHT | 2 |
JUSTIFY | 3 |
DISTRIBUTED | 4 |
TextAnchorType
TextAnchorType bir IntEnum bir şekil içinde dikey metin sabitlemesi için.
| Enumerations | Enumerations |
|---|---|
TOP | 0 |
MIDDLE | 1 |
BOTTOM | 2 |
JUSTIFIED | 3 |
MsoFillFormat
Bir şeklin dolgu görünümünü kontrol eder. Şu yolla erişilir shape.fill.
Enumerations
| Enumerations | Enumerations | Enumerations |
|---|---|---|
fill_type | FillType | Etkin dolgu türü. |
fore_color | str | Ön plan (birincil) doldurma rengi RRGGBB onaltılık. |
transparency | float | Doldurma opaklığı şu değerden 0.0 (tamamen opak) ile 1.0 (tamamen şeffaf). |
Enumerations
copy
fill.copy() -> MsoFillFormatBu doldurma ayarlarının derin bir kopyasını döndürür.
MsoLineFormat
Bir şeklin dış hat/kenar görünümünü kontrol eder. Şu yolla erişilir shape.line.
Enumerations
| Enumerations | Enumerations | Enumerations |
|---|---|---|
is_visible | bool | True şekil konturunu çizmek için. |
color | str | Kontur rengi RRGGBB onaltılık olarak. |
weight | int | Kontur kalınlığı (genişliği) puan cinsinden. |
dash_style | MsoLineDashStyle | Kontur için kesikli desen. |
transparency | float | Kontur opaklığı şu değerden 0.0 (opak) şu değere 1.0 (şeffaf). |
Enumerations
copy
line.copy() -> MsoLineFormatBu çizgi ayarlarının derin bir kopyasını döndürür.
ShapeFont
Bir şekil içindeki metin yazı tipini kontrol eder. Şu yolla erişilir: shape.font.
Enumerations
| Enumerations | Enumerations | Enumerations |
|---|---|---|
name | str | Yazı tipi ailesi adı (örneğin,., "Calibri"). |
size | float | Yazı tipi boyutu puan cinsinden. |
bold | bool | True kalın ağırlık için. |
italic | bool | True italik stil için. |
underline | bool | True tek alt çizgi için. |
color | str | Yazı tipi rengi RRGGBB onaltılık olarak. |
Enumerations
copy
font.copy() -> ShapeFontBu yazı tipi ayarlarının derin bir kopyasını döndürür.
Enumerations
Shape nesneler doğrudan oluşturulmaz. Şunu kullanın: ws.shapes.add(...) veya ws.shapes.add_text_box(...).
Enumerations
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
name | str | Okuma/Yazma | Şekil adı (çalışma sayfası içinde benzersiz olmalıdır). |
drawing_type | MsoDrawingType | Enumerations | Bu şeklin geometrik türü. |
upper_left_row | int | Okuma/Yazma | 0-based row index of the top-left anchor cell. |
upper_left_column | int | Okuma/Yazma | 0-based column index of the top-left anchor cell. |
lower_right_row | int | Okuma/Yazma | 0-based row index of the bottom-right anchor cell. |
lower_right_column | int | Okuma/Yazma | 0-based column index of the bottom-right anchor cell. |
upper_left_row_offset | int | Okuma/Yazma | Üst sol hücrenin üst kenarından piksel kayması. |
upper_left_column_offset | int | Okuma/Yazma | Üst sol hücrenin sol kenarından piksel kayması. |
lower_right_row_offset | int | Okuma/Yazma | Alt sağ hücrenin üst kenarından piksel kayması. |
lower_right_column_offset | int | Okuma/Yazma | Alt sağ hücrenin sol kenarından piksel kayması. |
fill | MsoFillFormat | Enumerations | Dolgu (arka plan) ayarları. |
line | MsoLineFormat | Enumerations | Anahat/kenar ayarları. |
text | str | Okuma/Yazma | Şekil içinde görüntülenen metin içeriği. |
font | ShapeFont | Enumerations | Şekil metni için yazı tipi ayarları. |
text_horizontal_alignment | TextAlignmentType | Okuma/Yazma | Şekil içindeki yatay metin hizalaması. |
text_vertical_alignment | TextAnchorType | Okuma/Yazma | Şekil içindeki dikey metin sabitlemesi. |
is_text_wrapped | bool | Okuma/Yazma | True metni şekil sınırında kaydırmak için. |
is_locked | bool | Okuma/Yazma | True çalışma sayfası koruması etkin olduğunda şekli kilitlemek için. |
is_hidden | bool | Okuma/Yazma | True şekli gizlemek için. |
hyperlink | `str | None` | Okuma/Yazma |
Enumerations
copy
shape.copy() -> ShapeBu şeklin tüm biçimlendirmeleri korunmuş bir derin kopyasını döndürür.
ShapeCollection
ShapeCollection olarak erişilir ws.shapes. Çalışma sayfasındaki tüm şekilleri içerir.
Enumerations
add
ws.shapes.add(
drawing_type: MsoDrawingType,
upper_left_row: int,
upper_left_column: int,
lower_right_row: int,
lower_right_column: int
) -> ShapeBelirtilen türde bir şekil ekler. Tüm konum argümanları 0 tabanlı satır/sütun indeksleridir.
add_text_box
ws.shapes.add_text_box(
upper_left_row: int,
upper_left_column: int,
lower_right_row: int,
lower_right_column: int
) -> ShapeKısayol: add(MsoDrawingType.TEXT_BOX, ...).
Özellikler ve Yineleme
| Enumerations | Enumerations |
|---|---|
count | Koleksiyondaki şekil sayısı (yalnızca okunur). |
__len__() | Enumerations count. |
__iter__() | Tüm … üzerinde yineleme yapar. Shape nesneler. |
__getitem__(index) | Şunu döndürür Shape sıfır tabanlı olarak index. |
Enumerations
Katı Dolgu ile bir Dikdörtgen ekle
from aspose.cells_foss import Workbook, MsoDrawingType, FillType, MsoLineDashStyle, TextAlignmentType
wb = Workbook()
ws = wb.worksheets[0]
# Add a blue rectangle spanning rows 1-5, columns 1-4 (0-based)
rect = ws.shapes.add(MsoDrawingType.RECTANGLE, 1, 1, 5, 4)
rect.name = "BlueBox"
rect.fill.fill_type = FillType.SOLID
rect.fill.fore_color = "4472C4" # blue
rect.fill.transparency = 0.0
rect.line.is_visible = True
rect.line.color = "1F3864" # dark blue
rect.line.weight = 2
rect.line.dash_style = MsoLineDashStyle.SOLID
rect.text = "Sales Summary"
rect.font.bold = True
rect.font.color = "FFFFFF" # white text
rect.font.size = 12
rect.text_horizontal_alignment = TextAlignmentType.CENTER
wb.save("shapes.xlsx")Bir Metin Kutusu ekle
from aspose.cells_foss import Workbook
wb = Workbook()
ws = wb.worksheets[0]
tb = ws.shapes.add_text_box(2, 0, 5, 3)
tb.name = "NoteBox"
tb.text = "Review this section before publishing."
tb.font.italic = True
tb.font.color = "595959"
tb.is_text_wrapped = True
tb.line.is_visible = True
tb.line.color = "BFBFBF"
wb.save("textbox.xlsx")