Skip to content

Index vs Address

Pierlam-dev edited this page Mar 28, 2026 · 5 revisions

There are two way to access a row or a cell:

  1. By Index

  2. By Address

It's related to the underlying OpenXML library. Only existing rows and cells are defined in an excel file.

Get a row or a cell by index

Access a row or a cell by index means you scan only existing ones. It's the way of running of the underlying OpenXML library.

If some rows are empty, there does not exists, so there is no data for them.

// get the index or position of the last existing row
int lastRowIdx = proc.GetLastRowIndex(excelSheet);

// get the row by index (in existing rows!), if the row doesn't exists, row is null, it's not an error
ExcelRow excelRow = proc.GetRowAtIndex(excelSheet, r);

// get cells of the row, only existing ones!
List<ExcelCell> listCells = proc.GetRowCells(excelSheet, excelRow);

Get a row or a cell by address

It's exactly like in Excel. You can get a cell by the "real" address which is named CellReference in Excel world.

// get the address of the last existing, even if some rows are empty
int lastRowAddr = proc.GetLastRowAddress(excelSheet);

// get the cell at the address C4, the cell can be null
ExcelCell cell = proc.GetCellAt(excelSheet, "C4");

Clone this wiki locally