-
Notifications
You must be signed in to change notification settings - Fork 295
Dimension (used range)
Mats Alm edited this page Sep 2, 2024
·
5 revisions
The ExcelWorksheet.Dimension property exposes an address that indicates the area of the worksheet that contains cell values, formulas or styling. 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
If you want to know the first or last value or the dimension for the worksheets cells having values, your can use the properties FirstValueCell, LastValueCell and DimensionByValue exposed by the ExcelWorksheet class.
EPPlus Software AB - https://epplussoftware.com
- What is new in EPPlus 5+
- Breaking Changes in EPPlus 5
- Breaking Changes in EPPlus 6
- Breaking Changes in EPPlus 7
- Breaking Changes in EPPlus 8
- Addressing a worksheet
- Dimension/Used range
- Copying ranges/sheets
- Insert/Delete
- Filling ranges
- Sorting ranges
- Taking and skipping columns/rows
- Data validation
- Comments
- Freeze and Split Panes
- Header and Footer
- Hyperlinks
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- The ExcelRange.Text property
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles