SettablePivotGlobalizationSettings.SetTextOfGrandTotal

SettablePivotGlobalizationSettings.SetTextOfGrandTotal method

Sets the text of “Grand Total” label in the PivotTable.

public void SetTextOfGrandTotal(string text)
ParameterTypeDescription
textStringcustom text

Examples

namespace AsposeCellsExamples
{
    using Aspose.Cells;
    using System;

    public class SettablePivotGlobalizationSettingsMethodSetTextOfGrandTotalWithStringDemo
    {
        public static void Run()
        {
            // Create a new workbook (context only)
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            worksheet.Cells["A1"].PutValue("Sample Data");

            // Instance of SettablePivotGlobalizationSettings
            SettablePivotGlobalizationSettings settings = new SettablePivotGlobalizationSettings();

            try
            {
                // Set a custom text for the "Grand Total" label
                settings.SetTextOfGrandTotal("My Custom Grand Total");

                // Retrieve the updated label text to verify the change
                string grandTotalText = settings.GetTextOfGrandTotal();

                Console.WriteLine($"Grand Total label text: {grandTotalText}");

                // Save the workbook just to demonstrate that the code runs without errors
                workbook.Save("SetTextOfGrandTotalDemo.xlsx");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error calling SetTextOfGrandTotal: {ex.Message}");
            }
        }
    }
}

See Also