Crea grafici Bubble3D tramite Python
Creazione di grafici MS Excel nativi e ad alte prestazioni a livello di codice utilizzando le API Python.
Come creare grafici Bubble3D tramite Python
È facile per gli sviluppatori creare un grafico Bubble3D eseguendo diverse applicazioni di reporting per l’elaborazione dei dati in poche righe di codice.
- Importa asposecells nel tuo file di codice.
- Crea un’istanza della classe Workbook.
- Aggiungi alcuni dati al foglio di lavoro.
- Aggiungi un grafico Bubble3D al foglio di lavoro
- Accedi al nuovo oggetto grafico dalla raccolta Charts passando il relativo indice.
- Imposta l’origine dati del grafico con il metodo Chart.setChartDataRange.
- Salva come file Excel.
Requisiti di sistema
Aspose.Cells for Python è indipendente dalla piattaforma API e può essere utilizzato su qualsiasi piattaforma (Windows, Linux e MacOS), assicurati solo che il sistema abbia Java 1.8 o versione successiva, Python 3.5 o superiore.
- Installa Java e aggiungilo alla variabile di ambiente PATH, ad esempio:PATH=C:\Program Files\Java\jdk1.8.0_131;
.
- Installa Aspose.Cells for Python dapypi , usa il comando come:$ pip install aspose-cells
.Il seguente codice sorgente mostra come creare un grafico Bubble3D nel file MS Excel XLSX utilizzando Python.
import jpype | |
import asposecells | |
jpype.startJVM() | |
from asposecells.api import Workbook, CellsHelper, FileFormatType, ChartType, License | |
# Instantiating a Workbook object | |
workbook = Workbook(FileFormatType.XLSX) | |
# Obtaining the reference of the first worksheet | |
worksheet = workbook.getWorksheets().get(0) | |
worksheet.getCells().get("A2").putValue("Category1") | |
worksheet.getCells().get("A3").putValue("Category2") | |
worksheet.getCells().get("A4").putValue("Category3") | |
worksheet.getCells().get("B1").putValue("Bubble3D") | |
worksheet.getCells().get("B2").putValue(300) | |
worksheet.getCells().get("B3").putValue(400) | |
worksheet.getCells().get("B4").putValue(200) | |
# Adding a Bubble3D chart to the worksheet | |
chartIndex = worksheet.getCharts().add(ChartType.BUBBLE3D, 6, 2, 22, 10) | |
# Accessing the instance of the newly added chart | |
chart = worksheet.getCharts().get(chartIndex) | |
# Setting chart data source as the range "A1:B4" | |
chart.setChartDataRange("A1:B4", True); | |
# Save the Workbook as .xlsx file. | |
workbook.save("output.xlsx"); |