Back to Devexpress

RangeExtensions.Sum(CellRange, Boolean, Boolean) Method

officefileapi-devexpress-dot-spreadsheet-dot-rangeextensions-dot-sum-x28-devexpress-dot-spreadsheet-dot-cellrange-system-dot-boolean-system-dot-boolean-x29.md

latest4.1 KB
Original Source

RangeExtensions.Sum(CellRange, Boolean, Boolean) Method

Returns the sum of numerical values in the current cell range.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public static double Sum(
    this CellRange range,
    bool ignoreHiddenRows,
    bool ignoreHiddenColumns
)
vb
<ExtensionAttribute>
Public Shared Function Sum(
    range As CellRange,
    ignoreHiddenRows As Boolean,
    ignoreHiddenColumns As Boolean
) As Double

Parameters

NameTypeDescription
rangeCellRange

A cell range for which the sum is calculated.

| | ignoreHiddenRows | Boolean |

true to exclude hidden rows from calculation; otherwise, false.

| | ignoreHiddenColumns | Boolean |

true to exclude hidden columns from calculation; otherwise, false.

|

Returns

TypeDescription
Double

The sum value. If cells are empty or don’t contain numeric values, this method returns 0.

|

Remarks

Use the following extension methods to summarize values in a cell range. You can call these methods in the same way as instance methods of the CellRange object.

MethodDescription
RangeExtensions.AverageReturns the average of numerical values in a cell range.
RangeExtensions.CountReturns the number of cells that contain data.
RangeExtensions.NumericalCountReturns the number of cells that contain numerical data.
RangeExtensions.SumReturns the sum of numerical values in a cell range.
RangeExtensions.MaxReturns the maximum numerical value in a cell range.
RangeExtensions.MinReturns the minimum numerical value in a cell range.

The following code example shows how to obtain summary values for selected cells in the Spreadsheet control.

csharp
CellRange selectedCells = spreadsheetControl1.Selection;
double average = selectedCells.Average(true, true);
double sum = selectedCells.Sum(true, true);
double count = selectedCells.Count(true, true);
double numCount = selectedCells.NumericalCount(true, true);
vb
Dim selectedCells As CellRange = spreadsheetControl1.Selection
Dim average As Double = selectedCells.Average(True, True)
Dim sum As Double = selectedCells.Sum(True, True)
Dim count As Double = selectedCells.Count(True, True)
Dim numCount As Double = selectedCells.NumericalCount(True, True)

See Also

RangeExtensions Class

RangeExtensions Members

DevExpress.Spreadsheet Namespace