Enum TotalsCalculation

TotalsCalculation enumeration

Determines the type of calculation in the Totals row of the list column.

public enum TotalsCalculation

Values

NameValueDescription
Sum6Represents Sum totals calculation.
Count2Represents Count totals calculation.
Average1Represents Average totals calculation.
Max4Represents Max totals calculation.
Min5Represents Min totals calculation.
Var8Represents Var totals calculation.
CountNums3Represents Count Nums totals calculation.
StdDev7Represents StdDev totals calculation.
None0Represents No totals calculation.
Custom9Represents custom calculation.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using Aspose.Cells.Tables;
    using System;

    public class TotalsCalculationDemo
    {
        public static void TotalsCalculationExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Cells cells = workbook.Worksheets[0].Cells;

            // Populate the worksheet with some data
            for (int i = 0; i < 5; i++)
            {
                cells[0, i].PutValue(CellsHelper.ColumnIndexToName(i));
            }
            for (int row = 1; row < 10; row++)
            {
                for (int column = 0; column < 4; column++)
                {
                    cells[row, column].PutValue(row * column);
                }
            }

            // Add a table to the worksheet
            ListObjectCollection tables = workbook.Worksheets[0].ListObjects;
            int index = tables.Add(0, 0, 9, 4, true);
            ListObject table = tables[index];

            // Show totals row
            table.ShowTotals = true;

            // Access the fifth column in the table
            ListColumn listColumn = table.ListColumns[4];

            // Set the TotalsCalculation property to Sum
            listColumn.TotalsCalculation = TotalsCalculation.Sum;

            // Optionally, set a formula for the column
            listColumn.Formula = "=[A]";

            // Save the workbook
            workbook.Save("TotalsCalculationExample.xlsx");
        }
    }
}

See Also