Skapa Bubble3D-diagram via Python
Native och högpresterande MS Excel-diagram skapas programmatiskt med hjälp av Python API:er.
Hur man skapar Bubble3D-diagram via Python
Det är lätt för utvecklarna att skapa ett Bubble3D-diagram inom att köra olika rapporteringsapplikationer för databehandling på bara några rader kod.
- Importera asposeceller i din kodfil.
- Skapa Workbook-klassinstans.
- Lägg till lite data till arbetsbladet.
- Lägg till ett Bubble3D-diagram till kalkylbladet
- Få tillgång till det nya diagramobjektet från diagramsamlingen genom att skicka dess index.
- Ställ in diagrammets datakälla med metoden Chart.setChartDataRange.
- Spara som Excel-filer.
Systemkrav
Aspose.Cells for Python är plattformsoberoende API och kan användas på vilken plattform som helst (Windows, Linux och MacOS), se bara till att systemet har Java 1.8 eller högre, Python 3,5 eller högre.
- Installera Java och lägg till den i PATH miljövariabel, till exempel:PATH=C:\Program Files\Java\jdk1.8.0_131;
.
- Installera Aspose.Cells for Python frånpypi , använd kommandot som:$ pip install aspose-cells
.Följande källkod visar hur man skapar ett Bubble3D-diagram till MS Excel XLSX-fil med 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"); |