C# EPPlus OpenXML count rows

rd42 picture rd42 · Jan 23, 2011 · Viewed 45k times · Source

With EPPlus and OpenXML does anyone know the syntax on how to count the rows?

Say my worksheet is called "worksheet"

int numberRows = worksheet.rows.count()? or worksheet.rows.dimension

I'm certainly interested in the answer, but how to find the answer would be cool to, like "Go to definition" and look for this or that, etc.

Answer

Quppa picture Quppa · Jan 24, 2011

With a worksheet object called worksheet, worksheet.Dimension.Start.Row and worksheet.Dimension.End.Row should give you the information you need.

worksheet.Dimension.Address will give you a string containing the worksheet dimensions in the traditional Excel range format (e.g. 'A1:I5' for rows 1-5, columns 1-9).

There is a documentation file available. In many cases it might be just as quick to play around with the library and find the answer that way. EPPlus seems to be well designed - everything seems to be logically named, at least.