﻿ AutoSum Functions | SpreadJS 13
SpreadJS Documentation / SpreadJS Designer / Work in the Designer / AutoSum Functions
In This Topic
AutoSum Functions
In This Topic

While using AutoSum functions in SpreadJS, such as sum, average, min, max etc, the range of cells on which the function should be applied is automatically calculated. When a cell is selected in a spreadsheet and a function is applied on it, the range is automatically highlighted. The calculation of range is based on the active cell and the calculated result is also displayed in the active cell.

Note: The automatic calculation of range is done only for the 'number' type fields.

The below gif depicts the automatic calculation of range when sum function is applied: ### Range Considered for Calculation

In case of numeric values:

• The upper and left region of the active cell containing numbers are considered.

Upper Region Left Region • The bottom and right region of the active cell containing numbers are not considered.

Bottom region Right Region • If both the upper and left region of the active cell contains numbers, the range of upper region is considered. • If there are numbers above the cell but not adjacent to the cell, the range includes empty cells until numbers are encountered and no empty cells afterwards (same for left region) In case of non-numeric value in cell:

• Complete range is considered if a non-numeric value exists adjacent to the active cell (same for left region). • If left and upper region both contain left and right contain data, and the upper region contains non-numeric value adjacent to the cell on which function is applied, the range of left region is considered. • If the non-numeric value exists in between, the range is considered till it is encountered. • If non-numeric values exists adjacent to the cell and in between too, the range is considered until the cell containing numbers is encountered and does not consider any non-numeric values afterwards. ### Special cases

If the top adjacent cells are empty, while the left adjacent cells are numbers, the left region is considered. The boundary of the range under consideration automatically expands to the width of a span. 