Aspose.Cells.Examples.CSharp.Articles.CustomLabelsSubtotals.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // ExStart:UsingGlobalizationSettings
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Loads an existing spreadsheet containing some data
            Workbook book = new Workbook(dataDir + "sample.xlsx");

            // Assigns the GlobalizationSettings property of the WorkbookSettings class to the class created in first step
            book.Settings.GlobalizationSettings = new CustomSettings();

            // Accesses the 1st worksheet from the collection which contains data resides in the cell range A2:B9
            Worksheet sheet = book.Worksheets[0];

            // Adds Subtotal of type Average to the worksheet
            sheet.Cells.Subtotal(CellArea.CreateCellArea("A2", "B9"), 0, ConsolidationFunction.Average, new int[] { 1 });

            // Calculates Formulas
            book.CalculateFormula();

            // Auto fits all columns
            sheet.AutoFitColumns();

            // Saves the workbook on disc
            book.Save(dataDir + "output_out.xlsx");
            // ExEnd:UsingGlobalizationSettings
        }
    }
CustomLabelsSubtotals