Enum ConsolidationFunction

ConsolidationFunction enumeration

Represents consolidation function.

public enum ConsolidationFunction

Values

NameValueDescription
Sum0Represents Sum function.
Count1Represents Count function.
Average2Represents Average function.
Max3Represents Max function.
Min4Represents Min function.
Product5Represents Product function.
CountNums6Represents Count Nums function.
StdDev7Represents StdDev function.
StdDevp8Represents StdDevp function.
Var9Represents Var function.
Varp10Represents Varp function.
DistinctCount11Represents Distinct Count function.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;

    public class ConsolidationFunctionDemo
    {
        public static void ConsolidationFunctionExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();

            // Add a new worksheet to the workbook
            Worksheet worksheet = workbook.Worksheets[0];

            // Add sample data to the worksheet
            worksheet.Cells["A1"].PutValue("Category");
            worksheet.Cells["A2"].PutValue("A");
            worksheet.Cells["A3"].PutValue("B");
            worksheet.Cells["A4"].PutValue("C");

            worksheet.Cells["B1"].PutValue("Value");
            worksheet.Cells["B2"].PutValue(10);
            worksheet.Cells["B3"].PutValue(20);
            worksheet.Cells["B4"].PutValue(30);

            // Define the cell area for subtotal
            CellArea cellArea = new CellArea
            {
                StartRow = 1,
                StartColumn = 0,
                EndRow = 3,
                EndColumn = 1
            };

            // Apply subtotal with Sum function
            worksheet.Cells.Subtotal(cellArea, 0, ConsolidationFunction.Sum, new int[] { 1 });

            // Apply subtotal with Average function
            worksheet.Cells.Subtotal(cellArea, 0, ConsolidationFunction.Average, new int[] { 1 });

            // Apply subtotal with Max function
            worksheet.Cells.Subtotal(cellArea, 0, ConsolidationFunction.Max, new int[] { 1 });

            // Apply subtotal with Min function
            worksheet.Cells.Subtotal(cellArea, 0, ConsolidationFunction.Min, new int[] { 1 });

            // Save the workbook
            workbook.Save("ConsolidationFunctionExample.xlsx");
            workbook.Save("ConsolidationFunctionExample.pdf");

            // Output the results
            Console.WriteLine("Workbook saved with subtotals applied.");
        }
    }
}

See Also