Aggregate Excel Functions
Shows how to easily get aggregate vales from a Range of Cells in Excel.
Includes: Sum. Average, Min and Max.
using System.Linq; using IronXL; WorkBook workbook = WorkBook.Load("test.xls"); WorkSheet sheet = workbook.WorkSheets.First(); //This is how we get range from Excel worksheet var range = sheet["A2:A8"]; //This is how we can get sum of all numeric cells within the range decimal sum = range.Sum(); //This is how we can get average value of all numeric cells within the range decimal avg = range.Avg(); //This is how we can get maximum value of all numeric cells within the range decimal max = range.Max(); //This is how we can get minimum value of all numeric cells within the range decimal min = range.Min();
Imports System.Linq Imports IronXL Private workbook As WorkBook = WorkBook.Load("test.xls") Private sheet As WorkSheet = workbook.WorkSheets.First() 'This is how we get range from Excel worksheet Private range = sheet("A2:A8") 'This is how we can get sum of all numeric cells within the range Private sum As Decimal = range.Sum() 'This is how we can get average value of all numeric cells within the range Private avg As Decimal = range.Avg() 'This is how we can get maximum value of all numeric cells within the range Private max As Decimal = range.Max() 'This is how we can get minimum value of all numeric cells within the range Private min As Decimal = range.Min()
Shows how to easily get aggregate vales from a Range of Cells in Excel.
Includes: Sum. Average, Min and Max.