Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for the feedback.
I have updated the code as per your feedback. Please check it and let us know if it is fine as per your requirement. In case you have any different requirement then this, please create the chart manually in MS Excel and post it here. We will check it soon.
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the first worksheet
Worksheets worksheets = workbook.getWorksheets();
Worksheet sheet = worksheets.getSheet(0);
//Adding some sample value to cells
Cells cells = sheet.getCells();
Cell cell = cells.getCell("A2");
cell.setValue("Series 1");
cell = cells.getCell("A3");
cell.setValue("Series 2");
cell = cells.getCell("A4");
cell.setValue("Series 3");
cell = cells.getCell("B1");
cell.setValue("B-GROUP");
cell = cells.getCell("B2");
cell. setValue (100);
cell = cells.getCell("B3");
cell.setValue(150);
cell = cells.getCell("B4");
cell.setValue(75);
cell = cells.getCell("C1");
cell.setValue("C-GROUP");
cell = cells.getCell("C2");
cell.setValue(20);
cell = cells.getCell("C3");
cell.setValue(50);
cell = cells.getCell("C4");
cell.setValue(90);
Charts charts = sheet.getCharts();
//Adding a chart to the worksheet
Chart chart = charts.addChart(ChartType.PYRAMID,5,0,15,5);
//Adding NSeries (chart data source) to the chart
NSeries series = chart.getNSeries();
series.add("B1:C4", false);
series.setCategoryData("B1:C1");
for(int i=0;i<series.size();i++)
{
series.get(i).setName("=A"+(i+2));
}
chart.getCategoryAxis().setRotation(45);
//Saving the Excel file
workbook.save("D:\\book1.xls");
Thank You & Best Regards,