Need help in creating the 100% Stacked Column chart with a combination of column chart similar to that attached Excel using Aspose.Cells for Java API.
Attached below is a sample Excel file with the manually created for the required chart. Sample-sv100.zip (10.1 KB)
Please see the following sample code to accomplish your task. I have used your Excel XLSX file for source data for the new chart (I created) in the same worksheet in parallel to your original chart. You may refer to the code segment and may add/update code for your needs:
e.g. Sample code:
Workbook workbook = new Workbook("f:\\files\\Sample-sv100.xlsx");
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
int c = worksheet.getCharts().add(ChartType.COLUMN_100_PERCENT_STACKED, 10, 15, 39, 30);
Chart chart = worksheet.getCharts().get(c);
short sValue = 100;
short sGap = 9;
SeriesCollection serieses = chart.getNSeries();
int i = serieses.add("=(Report1!$D$2,Report1!$D$5)", false);
serieses.get(i).setName("Beer");
serieses.get(i).setOverlap(sValue);
serieses.get(i).setGapWidth(sGap);
i = serieses.add("=(Report1!$D$3,Report1!$D$6)", false);
serieses.get(i).setName("Wine");
serieses.get(i).setOverlap(sValue);
serieses.get(i).setGapWidth(sGap);
i = serieses.add("=(Report1!$D$4,Report1!$D$7)", false);
serieses.get(i).setName("Jin");
serieses.get(i).setOverlap(sValue);
serieses.get(i).setGapWidth(sGap);
sValue = -100;
sGap = 320;
i = serieses.add("=(Report1!$C$2,Report1!$C$5)", false);
serieses.get(i).setName("subTotal");
serieses.get(i).setPlotOnSecondAxis(true);
serieses.get(i).setOverlap(sValue);
serieses.get(i).setGapWidth(sGap);
serieses.get(i).getDataLabels().setShowValue(true);
serieses.get(i).getDataLabels().setPosition(LabelPositionType.ABOVE);
serieses.get(i).getArea().setFormatting(FormattingType.NONE);
serieses.setCategoryData("=(Report1!$A$2,Report1!$A$5)");
chart.setShowLegend(true);
chart.getLegend().setPosition(LegendPositionType.BOTTOM);
// Saving the Excel file
workbook.save("f:\\files\\out1.xlsx");
Please find attached the output XLSX file (containing the newly created chart) for your reference. out1.zip (11.7 KB)