Excel API Library for Java - Sample Browser | Document Solutions | Doughnut chart
[
フレーム]
src="bundle.js">
Refer to the following example code to see how to add a doughnut chart in Document Solutions for Excel.
// Create a new workbook
Workbook workbook = new Workbook();
IWorksheet worksheet = workbook.getWorksheets().get(0);
IShape shape = worksheet.getShapes().addChart(ChartType.Doughnut, 250, 20, 360, 230);
worksheet.getRange("A1:B6").setValue(new Object[][]{
{"S1", "S2"},
{10, 25},
{51, 36},
{52, 85},
{22, 65},
{23, 69},
});
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B6"), RowCol.Columns);
shape.getChart().getChartTitle().setText("Doughnut Chart");
shape.getChart().getChartGroups().get(0).setDoughnutHoleSize(50);
shape.getChart().getSeriesCollection().get(0).setHasDataLabels(true);
shape.getChart().getSeriesCollection().get(1).setHasDataLabels(true);
shape.getChart().getSeriesCollection().get(1).setExplosion(2);
// Save to an excel file
workbook.save("Pie_DoughnutChart.xlsx");
// Create a new workbook
var workbook = Workbook()
val worksheet = workbook.worksheets.get(0)
val shape = worksheet.shapes.addChart(ChartType.Doughnut, 250.0, 20.0, 360.0, 230.0)
worksheet.getRange("A1:B6").value = arrayOf(arrayOf
("S1", "S2"), arrayOf(10, 25), arrayOf(51, 36), arrayOf(52, 85), arrayOf(22, 65), arrayOf(23, 69))
shape.chart.seriesCollection.add(worksheet.getRange("A1:B6"), RowCol.Columns)
shape.chart.chartTitle.text = "Doughnut Chart"
shape.chart.chartGroups.get(0).doughnutHoleSize = 50
shape.chart.seriesCollection.get(0).hasDataLabels = true
shape.chart.seriesCollection.get(1).hasDataLabels = true
shape.chart.seriesCollection.get(1).explosion = 2
// Save to an excel file
workbook.save("Pie_DoughnutChart.xlsx")