Skip to content

Worksheet & Ranges

Most work in EPPlus starts with a range. You address cells through the indexer of the ExcelWorksheet.Cells property, which returns an ExcelRange, and use its properties and methods to read, write, copy, sort and format the cells. This section covers working with ranges and the worksheet-level features that apply to them.

Addressing ranges

  • Addressing a worksheet - How to address cells and ranges, and how to use relative addresses with the Offset method.
  • Dimension/Used range - Find the area of the worksheet that contains values, formulas or styling, or only values.

Working with ranges

  • Copying ranges/sheets - Copy ranges, values without formulas, styles or entire worksheets, within a workbook or to another workbook.
  • Insert/Delete - Insert and delete rows, columns and ranges. EPPlus adjusts formulas, tables, pivot tables, conditional formatting, drawings and other references in the workbook.
  • Filling ranges - Fill a range with numbers, dates or a list of values with FillNumber, FillDateTime and FillList.
  • Sorting ranges - Sort the rows or columns of a range on one or more columns or rows, ascending, descending or by a custom list.
  • Taking and skipping columns/rows - Select parts of a range without knowing its size, for example the result of a dynamic array formula or a LoadFrom... method.

Data validation and comments

  • Data validation - Restrict what can be entered in cells, with whole numbers, decimals, lists, dates, times or custom formulas.
  • Comments - Add and read comments (notes) and threaded comments.

Layout and presentation

  • Freeze and Split Panes - Freeze rows and columns, for example a header row, or split the worksheet into separate panes.
  • Header and Footer - Set headers and footers for printed worksheets, including page numbers, dates and other automatic text.
  • Hyperlinks - Add hyperlinks to cells and drawings, and style them with a named style.
  • Autofit columns - Adjust column widths to fit their content, and how EPPlus measures text.
  • Grouping and Ungrouping Rows and Columns - Group rows and columns into outlines that can be expanded and collapsed.

See also