IRONSOFTWAREHOME
Master Excel Aggregate Functions in C#
using IronXL;
using System.Linq;

WorkBook workBook = WorkBook.Load("sample.xls");
WorkSheet workSheet = workBook.WorkSheets.First();

// Get range from worksheet
var range = workSheet["A1:A8"];

// Apply sum of all numeric cells within the range
decimal sum = range.Sum();

// Apply average value of all numeric cells within the range
decimal avg = range.Avg();

// Identify maximum value of all numeric cells within the range
decimal max = range.Max();

// Identify minimum value of all numeric cells within the range
decimal min = range.Min();
Imports IronXL
Imports System.Linq

Dim workBook As WorkBook = WorkBook.Load("sample.xls")
Dim workSheet As WorkSheet = workBook.WorkSheets.First()

' Get range from worksheet
Dim range = workSheet("A1:A8")

' Apply sum of all numeric cells within the range
Dim sum As Decimal = range.Sum()

' Apply average value of all numeric cells within the range
Dim avg As Decimal = range.Avg()

' Identify maximum value of all numeric cells within the range
Dim max As Decimal = range.Max()

' Identify minimum value of all numeric cells within the range
Dim min As Decimal = range.Min()
NuGet Download
PM > Install-Package IronXL.Excel
Master Excel Aggregate Functions in C#

Master Excel Aggregate Functions in C#

The code example above shows how to easily get aggregate values from a range of cells in an Excel spreadsheet. However, please note that any non-numerical cell will be left out.

Sum

The method Sum() returns the total sum of the selected range of cells.

Average

The method Avg() returns the average of the selected range of cells.

Minimum

The method Min() returns the minimum number among the selected range of cells.

Maximum

The method Max() returns the maximum number among the selected range of cells.

For more flexibility, the above functions can also be applied to single/multiple rows or columns. Learn more about selecting rows and columns.

Explore Math Functions in Excel Using C#
View on GitHub

Ready to Get Started?

Nuget Downloads 2,280,941Version:2026.10just released

Key in blue circle

Get your free 30-day Trial Key instantly

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronXL
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get a Quote, No Obligation
Your details will always be kept confidential.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Trusted by Millions of Engineers Worldwide
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.10

PM > Install-Package IronXL.Excel
nuget.org/packages/IronXL.Excel/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronXL"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.10

  1. Download and unzip IronXL to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronXL.dll"

Licenses from $999