Buat Bagan Bubble3D melalui Python
Pembuatan Grafik MS Excel asli dan berkinerja tinggi secara terprogram menggunakan API Python.
Cara Membuat Chart Bubble3D melalui Python
Mudah bagi pengembang untuk membuat bagan Bubble3D dalam menjalankan berbagai aplikasi pelaporan untuk pemrosesan data hanya dalam beberapa baris kode.
- Impor sel aspose dalam file kode Anda.
- Buat instance kelas Buku Kerja.
- Tambahkan beberapa data ke lembar kerja.
- Tambahkan bagan Bubble3D ke lembar kerja
- Akses objek grafik baru dari koleksi Charts dengan meneruskan indeksnya.
- Tetapkan sumber data diagram dengan metode Chart.setChartDataRange.
- Simpan sebagai file Excel.
Persyaratan sistem
Aspose.Cells for Python tidak bergantung pada platform API dan dapat digunakan pada platform apa pun (Windows, Linux dan MacOS), pastikan saja sistem memiliki Java 1.8 atau lebih tinggi, Python 3,5 atau lebih tinggi.
- Instal Java dan tambahkan ke variabel lingkungan PATH, misalnya:PATH=C:\Program Files\Java\jdk1.8.0_131;
.
- Instal Aspose.Cells for Python daripypi , gunakan perintah sebagai:$ pip install aspose-cells
.Kode sumber berikut menunjukkan cara membuat Bagan Bubble3D ke file MS Excel XLSX menggunakan 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"); |