We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Legend order has interchanged when series name have more characters

Hi Team,

I am trying to generate the Stacked Column Chart in excel. I am using aspose-cells-8.6.2.1.jar. When I am having large number of characters for the series name, the legend entries order has interchanged in Excel 2013. But its working fine in Excel 2010. Could you please help me to resolve this issue. Herewith I have attached the Excels for your reference.

In the attached excel,
when we are having the series name as “FEB and MAR” its working fine. But when we are adding some chars to the series as like “FEB_values_get_changed_if_more_chars” and “MAR__values_get_changed_if_more_chars”, the legend order has interchanged.

Thanks
Prabu R

Hi Prabu,


Thank you for contacting Aspose support.

We have evaluated the presented scenario while using the latest version of Aspose.Cells for Java 8.6.3.2 and the code provided at the bottom of this post. You may observe from the attached resultant spreadsheets that the sequence of the legend entries remain the same regardless of series’s names length. Please give a try to the latest version on your side as well. In case the problem persists, please provide us an executable standalone sample application (along with supporting documents) in order to replicate the issue on our end.

Java

//Create new workbook
Workbook workbook = new Workbook(FileFormatType.XLSX);
//Access first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
//Add data for chart
//Category Axis Values
worksheet.getCells().get(“A2”).putValue(“1997”);
worksheet.getCells().get(“A3”).putValue(“1996”);
worksheet.getCells().get(“A4”).putValue(“2000”);
//First vertical series
worksheet.getCells().get(“B1”).putValue(“JAN”);
worksheet.getCells().get(“B2”).putValue(31.988435125);
worksheet.getCells().get(“B3”).putValue(35.766668);
worksheet.getCells().get(“B4”).putValue(38.5967573125);
//Second vertical series
worksheet.getCells().get(“C1”).putValue(“FEB_values_get_changed_if_more_chars”);
worksheet.getCells().get(“C2”).putValue(11.173128421875);
worksheet.getCells().get(“C3”).putValue(12.8615112597656);
worksheet.getCells().get(“C4”).putValue(15.8899079570312);
//Third vertical series
worksheet.getCells().get(“D1”).putValue(“MAR__values_get_changed_if_more_chars”);
worksheet.getCells().get(“D2”).putValue(21.81530665625);
worksheet.getCells().get(“D3”).putValue(22.90515671875);
worksheet.getCells().get(“D4”).putValue(24.70684915625);
//Fourth vertical series
worksheet.getCells().get(“E1”).putValue(“APR”);
worksheet.getCells().get(“E2”).putValue(0);
worksheet.getCells().get(“E3”).putValue(0);
worksheet.getCells().get(“E4”).putValue(5.56675854944684);
//Fifth vertical series
worksheet.getCells().get(“F1”).putValue(“MAY”);
worksheet.getCells().get(“F2”).putValue(0);
worksheet.getCells().get(“F3”).putValue(0);
worksheet.getCells().get(“F4”).putValue(7.9);
//Sixth vertical series
worksheet.getCells().get(“G1”).putValue(“JUN”);
worksheet.getCells().get(“G2”).putValue(0);
worksheet.getCells().get(“G3”).putValue(0);
worksheet.getCells().get(“G4”).putValue(-2.2);
//Seventh vertical series
worksheet.getCells().get(“H1”).putValue(“JUL”);
worksheet.getCells().get(“H2”).putValue(0);
worksheet.getCells().get(“H3”).putValue(0);
worksheet.getCells().get(“H4”).putValue(2830.0893125);
//Eighth vertical series
worksheet.getCells().get(“I1”).putValue(“AUG”);
worksheet.getCells().get(“I2”).putValue(0);
worksheet.getCells().get(“I3”).putValue(0);
worksheet.getCells().get(“I4”).putValue(1028.39669726562);
//Ninth vertical series
worksheet.getCells().get(“J1”).putValue(“SEP”);
worksheet.getCells().get(“J2”).putValue(0);
worksheet.getCells().get(“J3”).putValue(0);
worksheet.getCells().get(“J4”).putValue(1801.6924375);
//Tenth vertical series
worksheet.getCells().get(“K1”).putValue(“OCT”);
worksheet.getCells().get(“K2”).putValue(31.8025198235608);
worksheet.getCells().get(“K3”).putValue(35.9594896001093);
worksheet.getCells().get(“K4”).putValue(35.9872407015209);
//Eleventh vertical series
worksheet.getCells().get(“L1”).putValue(“NOV”);
worksheet.getCells().get(“L2”).putValue(60.2307368142062);
worksheet.getCells().get(“L3”).putValue(64.1347756475009);
worksheet.getCells().get(“L4”).putValue(68.9498499595286);
int idx = worksheet.getCharts().add(ChartType.COLUMN_STACKED, 6, 5, 25, 23);
Chart ch = worksheet.getCharts().get(idx);
ch.setChartDataRange(“A1:L4”, true);
//Save the workbook
workbook.save(dir + “output(long_series_names).xlsx”, SaveFormat.XLSX);