@SriG,
See the following sample code for your reference. I used your new file’s data as source data for the Bar chart that I created in the first sheet.
e.g.
Sample code:
Workbook workbook = new Workbook("f:\\files\\multibar+label.xlsx");
//Obtaining the reference of the first worksheet
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet sheet = worksheets.get(0);
ChartCollection charts = sheet.getCharts();
//Adding a chart to the worksheet
int chartIndex = charts.add(ChartType.BAR,23,1,43,17);
Chart chart = charts.get(chartIndex);
SeriesCollection serieses = chart.getNSeries();
serieses.add("DataSheet!B2:C8", true);
//set the range of category axis values
//serieses.setCategoryData("DataSheet!A2:A8");
//set names of the series
for ( int i = 0 ;i < serieses.getCount(); i ++ )
{
Series series = serieses.get(i);
series.setName(workbook.getWorksheets().get(1).getCells().get(0,i+1).getValue().toString());
}
// get the third series
Series series2 = serieses.get(1);
series2.setType(ChartType.BAR);
series2.getDataLabels().setShowValue(true);
series2.getDataLabels().setPosition(LabelPositionType.OUTSIDE_END);
Integer value = 35;
short v = value.shortValue();
series2.setGapWidth(v);
Integer value1 = 100;
short v1 = value1.shortValue();
series2.setOverlap(v1);
series2.getArea().setFormatting(FormattingType.NONE);
//chart.getSecondValueAxis().setVisible(true);
// Move the legend to the bottom
chart.getLegend().setPosition(LegendPositionType.BOTTOM);
workbook.save("f:\\files\\output2.xlsx");
Let us know if you still find any issue.