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

Free Support Forum - aspose.com

Custom Series DataLabel Separator

Is there a way to set the Series DataLabel Separator for a pie chart to a custom value? I am trying to get Excel to mimic and existing chart and in this case the separator is " - " (displaying as 6 - 75%).

Hi Shane,

Thanks for your posting and using Aspose.Cells

Please try chart.NSeries[x].DataLabels.Separator for your needs. If you still find any issue, then please provide us your sample input and expected output xls/xlsx files which you can create manually using MS-Excel and attach them here. It will help us look into your issue more precisely and we will update you asap.

I don’t see access to that in the Java version of Apose Cells. All I see is chart.getNSeries().get(0).getDataLabels().setSeparator(int) that takes a DataLablesSeparatorType…


Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.getWorksheets().add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
//Adding a sample value to “A1” cell
worksheet.getCells().get(“A1”).putValue(“Standard”);
//Adding a sample value to “A2” cell
worksheet.getCells().get(“A2”).putValue(“High”);
//Adding a sample value to “A3” cell
worksheet.getCells().get(“A3”).putValue(“Critical”);
//Adding a sample value to “B1” cell
worksheet.getCells().get(“B1”).putValue(6);
//Adding a sample value to “B2” cell
worksheet.getCells().get(“B2”).putValue(1);
//Adding a sample value to “B3” cell
worksheet.getCells().get(“B3”).putValue(1);

//Adding a chart to the worksheet
int chartIndex = worksheet.getCharts().add(ChartType.PIE, 5, 0, 25, 10);
//Accessing the instance of the newly added chart
Chart chart = worksheet.getCharts().get(chartIndex);
//Adding NSeries (chart data source) to the chart ranging from “A1” cell to “B4”
chart.getNSeries().add(“B1:B3”, true);
//Setting the data source for the category data of NSeries
chart.getNSeries().setCategoryData(“A1:A3”);
Series series = chart.getNSeries().get(0);
//Setting the values of the series.
series.setValues(“B1:B3”);
//Setting the data label
series.getDataLabels().setPosition(LabelPositionType.OUTSIDE_END);
series.getDataLabels().setShowPercentage(true);
series.getDataLabels().setShowValue(true);
series.getDataLabels().setSeparator(DataLablesSeparatorType.SPACE);
// is there a way to set the seperator as " - "
series.getDataLabels().setNumberFormat(“0.00%”);
series.getBorder().setStyle(LineType.SOLID);
series.getBorder().setColor(Color.getWhite());
series.getLeaderLines().setStyle(LineType.SOLID);
series.getLeaderLines().setColor(Color.getBlack());
chart.getLegend().setPosition(LegendPositionType.RIGHT);

Hi Shane,

You are right, in the Java version of the API DataLabels.Separator property has changed into DataLabels.setSeparator method that accepts an int value, and can be selected using the enum DataLablesSeparatorType.

Please note, you have the following possible options,

  1. Auto
  2. Comma
  3. New Line
  4. Period
  5. Semicolon
  6. Space

Please feel free to write back in case you have further questions or concerns.

So the answer is No it’s not possible to set a custom separator.


I’d like to ask that you take it into consideration as an enhancement. Excel allows it and apparently so does the .net version of Aspose Cells.

Thank you very much for your quick response.

Hi Shane,

Thanks for using Aspose.Cells.

I have checked in MS-Excel, you cannot specify custom separator for series data labels. There are just 5 built-in options as mentioned by Babar earlier.

I have attached the screenshot for your reference. If you think, custom separator can be specified, then please provide us some sample xls/xlsx file containing custom separator and also let us know the steps you performed to specify it. You can create such file manually in MS-Excel for our reference.

We will look into it and implement this feature if possible.

Screenshot:

In reference to your screen shot although it is a combo box you can still type in the separator field. Attached is a sample xls with the separator set to " - ".

Hi Shane,

Thank you for the sample spreadsheet.

We have logged a ticket (CELLSJAVA-40753) in our bug tracking system to look further into this matter. Please spare us little time to properly analyze the request, and to provide the implementation at earliest. In the meanwhile, we will keep you posted with updates in this regard.

Hi,

Thanks for your using Aspose.Cells for Java.

Please download and try this fix: Aspose.Cells for Java v7.7.2.4 and use setSeparatorValue(String value) for setting custom separator.

Let us know your feedback.

That method works as expected. Thank you.

Hi,



Good to know that your issue is resolved by the new fix/version. We have closed your ticket now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.

The issues you have found earlier (filed as CELLSJAVA-40753) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.