Using GlobalizationSettings Class for Custom Subtotal Labels and Other Label of Pie Chart

Possible Usage Scenarios

Aspose.Cells APIs have exposed the GlobalizationSettings class in order to deal with the scenarios where the user wishes to use custom labels for Subtotals in a spreadsheet. Moreover, the GlobalizationSettings class can also be used to modify the Other label for the Pie chart while rendering worksheet or chart.

Introduction to GlobalizationSettings Class

The GlobalizationSettings class currently offers the following 3 methods which can be overridden in a custom class to get desired labels for the Subtotals or to render custom text for the Other label of a Pie chart.

  1. GlobalizationSettings.getTotalName: Gets the total name of the function.
  2. GlobalizationSettings.getGrandTotalName: Gets the grand total name of the function.
  3. GlobalizationSettings.getOtherName: Gets the name of “Other” labels for Pie charts.

Custom Labels for Subtotals

The GlobalizationSettings class can be used to customize the Subtotal labels by overriding the GlobalizationSettings.getTotalName & GlobalizationSettings.getGrandTotalName methods as demonstrated ahead.

In order to inject custom labels, it is required to assign the WorkbookSettings.GlobalizationSettings property to an instance of the CustomSettings class defined above before adding the Subtotals to the worksheet.

Custom Text for Other Label of Pie Chart

The GlobalizationSettings class offers the getOtherName method which is useful to give the “Other” label of Pie charts a custom value. The following snippet defines a custom class and overrides the getOtherName method to get a custom label based on default language set for JVM.

The following snippet loads an existing spreadsheet containing a Pie chart and renders the chart to an image while utilizing the CustomSettings class created above.

Following is the resultant image when locale of the machine is set to France. As you can see that the label “Other” has been translated to “Autre” as defined in CustomSettings class.

todo:image_alt_text