Tabella
Contents
[
Hide
]
Esempi per aggiungere tabelle, accedervi, rimuoverle e unire le celle utilizzando Aspose.Slides for Python via Java.
Installa il pacchetto come descritto in Installation. Ogni esempio importa asposeslides prima di avviare la JVM, quindi importa l’API dopo che la JVM è in esecuzione.
Aggiungi una tabella
Crea una tabella semplice con due righe e due colonne.
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Presentation
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
widths = jpype.JArray(jpype.JDouble)([80, 80])
heights = jpype.JArray(jpype.JDouble)([30, 30])
table = slide.getShapes().addTable(50, 50, widths, heights)
finally:
presentation.dispose()
Accedi a una tabella
Recupera la prima forma di tabella nella diapositiva.
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Presentation, Table
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
widths = jpype.JArray(jpype.JDouble)([80, 80])
heights = jpype.JArray(jpype.JDouble)([30, 30])
table = slide.getShapes().addTable(50, 50, widths, heights)
# Accedi alla prima tabella nella diapositiva.
first_table = None
for index in range(slide.getShapes().size()):
shape = slide.getShapes().get_Item(index)
if isinstance(shape, Table):
first_table = shape
break
finally:
presentation.dispose()
Rimuovi una tabella
Elimina una tabella da una diapositiva.
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Presentation
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
widths = jpype.JArray(jpype.JDouble)([80, 80])
heights = jpype.JArray(jpype.JDouble)([30, 30])
table = slide.getShapes().addTable(50, 50, widths, heights)
slide.getShapes().remove(table)
finally:
presentation.dispose()
Unisci le celle della tabella
Unisci le celle adiacenti di una tabella in un’unica cella.
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Presentation
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
widths = jpype.JArray(jpype.JDouble)([80, 80])
heights = jpype.JArray(jpype.JDouble)([30, 30])
table = slide.getShapes().addTable(50, 50, widths, heights)
# Unisci le celle.
table.mergeCells(table.get_Item(0, 0), table.get_Item(1, 1), False)
finally:
presentation.dispose()