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.
- GlobalizationSettings.GetTotalName: Gets the total name of the function.
- GlobalizationSettings.GetGrandTotalName: Gets the grand total name of the function.
- 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 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 the system’s culture identifier.
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.