bilgestackoverflow
bilgestackoverflow

Reputation: 329

excel find range of a cell in C#

How can the range of a cell in excel be found through C# code?

xlWorkSheet.Cells[row + 1, col + 1]

I want to find out this cell's range.

Thanks in advance

Upvotes: 0

Views: 1933

Answers (1)

CapelliC
CapelliC

Reputation: 60004

Excel exposes an object Range. You can access cells, for instance

rng = (Excel.Range)xlWorkSheet.Cells[row + 1, col + 1];

This statement should select a single cell. To get all the cells of the row 1 (always as Range):

rng = (Excel.Range)ws.Rows[1, Type.Missing];

Upvotes: 1

Related Questions