Skip to content

Dimension (used range)

Mats Alm edited this page Mar 4, 2024 · 5 revisions

The ExcelWorksheet.Dimension property exposes an address that indicates the area of the worksheet that contains cell values. See example below:

using var package = new ExcelPackage();
var sheet = package.Workbook.Worksheets.Add("Sheet 1");
sheet.Cells["A1"].Value = 1;
sheet.Cells["A2"].Value = 2;
sheet.Cells["A3"].Value = 3;
sheet.Cells["B1"].Value = 4;
sheet.Cells["B2"].Value = 5;
sheet.Cells["B3"].Value = 6;
Console.WriteLine($"Dimension address: {sheet.Dimension.Address}");
Console.WriteLine($"Dimension from row: {sheet.Dimension.Start.Row}");
Console.WriteLine($"Dimension to row: {sheet.Dimension.End.Row}");
Console.WriteLine($"Dimension from column: {sheet.Dimension.Start.Column}");
Console.WriteLine($"Dimension to column: {sheet.Dimension.End.Column}");

This code will result in the following output:

Dimension address: A1:B3
Dimension from row: 1
Dimension to row: 3
Dimension from column: 1
Dimension to column: 2

EPPlus wiki

Versions

Worksheet & Ranges

Styling

Import/Export data

Formulas and filters

Charts & Drawing objects

Tables & Pivot Tables

VBA & Protection

Clone this wiki locally